File Upload API
将本地数据文件上传到内部或外部的具名 Stage。
REST API
该 API 将文件放在请求正文并 POST 到 /v1/upload_to_stage
,返回包含查询状态的 JSON。
参数 | 描述 | 必填 |
---|---|---|
stage_name:<your-stage-name> | Stage 名称的 HTTP 头 | 是 |
upload=@<your-file-path> | 您要上传的文件路径 | 是 |
示例
- Upload to Named Internal Stage
- Upload to Named External Stage
此示例显示如何将文件上传到命名的内部阶段。
- 从 MySQL 客户端创建一个具名的内部 Stage:
CREATE STAGE my_internal_stage;
- 下载并上传样本文件:
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"]}
查看 Stage 上的文件:
LIST @my_internal_stage;
+---------------+
| file_name |
+---------------+
| books.parquet |
+---------------+
文件 books.parquet
已经成功上传。
此示例显示如何将文件上传到命名的外部阶段。
- 从 MySQL 客户端创建一个具名的外部 Stage:
CREATE STAGE my_external_stage url = 's3://testbucket/admin/data/' credentials=(aws_key_id='minioadmin' aws_secret_key='minioadmin');
- 下载并上传样本文件:
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"]}
查看 Stage 上的文件:
LIST @my_external_stage;
+---------------+
| file_name |
+---------------+
| books.parquet |
+---------------+
文件 books.parquet
已经成功上传。