Skip to main content

File Upload API

Uploads local data files to a named internal or external stage.

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.

ParameterDescriptionRequired
stage_name:<your-stage-name>HTTP header of the stage nameYES
upload=@<your-file-path>Path of the file you want to uploadYES

Examples

This example shows how to upload a file to a named internal stage.

  1. Create a named internal stage from MySQL client:
CREATE STAGE my_internal_stage;
  1. Download and upload the sample file:

Download books.parquet

Put books.parquet to stage
curl -u root: -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"]}

Check the staged file:

LIST @my_internal_stage;

name |size|md5|last_modified |creator|
-------------+----+---+-----------------------------+-------+
books.parquet| 998| |2023-04-19 19:34:51.303 +0000| |

The file books.parquet has been uploaded to your named internal stage.