PUT to Stage
Overview
Uploads data files from a local file system directory/folder on a client machine to Databend named internal stages.
REST API
- A POST to
/v1/upload_to_stage
uploads the file to the server stage with stream in the POST body, and returns a JSON containing the query status.
Parameters | Description | Required |
---|---|---|
stage_name:<your-stage-name> | The client header of the internal stage name | YES |
update=@<your-file-path> | The file path which will be upload to the stage | YES |
Quick Example
- Put to Named Internal Stage
- Put to Named External Stage
This example show how we update a file to a named internal stage.
- Create a named internal stage from MySQL client:
CREATE STAGE my_internal_stage;
- Download sample data and PUT to stage
Download books.parquet
Put books.parquet to stage
curl -H "stage_name:my_internal_stage" -F "upload=@books.parquet" -XPUT "http://localhost:8000/v1/upload_to_stage"
Response
{"id":"a3b21915-b3a3-477f-8e31-b676074539ea","stage_name":"my_internal_stage","state":"SUCCESS","files":["books.parquet"]}
Then check the stage files with:
LIST @my_internal_stage;
+---------------+
| file_name |
+---------------+
| books.parquet |
+---------------+
The file books.parquet
has PUT to your named internal stage.
This example show how we update a file to a named external stage.
- Create a named internal stage from MySQL client:
CREATE STAGE my_external_stage url = 's3://testbucket/admin/data/' credentials=(aws_key_id='minioadmin' aws_secret_key='minioadmin');
- Download sample data and PUT to stage
Download books.parquet
Put books.parquet to stage
curl -H "stage_name:my_external_stage" -F "upload=@books.parquet" -XPUT "http://localhost:8000/v1/upload_to_stage"
Response
{"id":"a3b21915-b3a3-477f-8e31-b676074539ea","stage_name":"my_external_stage","state":"SUCCESS","files":["books.parquet"]}
Then check the stage files with:
LIST @my_external_stage;
+---------------+
| file_name |
+---------------+
| books.parquet |
+---------------+
The file books.parquet
has PUT to your named external stage.