How to Upload Local Files
How to quickly upload local files to create data sources
The POST api/v1/datasets/{datasetId}/datasources
and POST /v1/datasources
endpoints allow you to upload your data in two methods:
-
From a public URL: Use the
url
parameter. -
From your local storage: Use the
fileKey
parameter.
This guide focuses on the latter—uploading a local file to create a data source.
Authentication
All requests to Powerdrill must include an x-pd-api-key
header with your API key.
To get your API key, see Quick Start.
Step 1. Upload your local file and obtain the fileKey
Use the POST /v1/file/upload_datasource endpoint to upload your local file. After the upload, the response will include a fileKey
. Save this fileKey
to create a data source using the Create data source endpoint.
Supported file formats include: .csv, .tsv, .md, .mdx, .json, .txt, .pdf, .pptx, .ppt, .doc, .docx, .xls, and .xlsx.
Here’s an example in cURL:
When making a request:
-
Replace
<api-key>
with your actual API key. -
Replace
<file_path>
with the actual full path to your file, for example,/Users/test/workspace/sales_2024.csv
.
Here’s an example response:
Extract the fileKey
value from the response for later use. In this example, it is /tmp/sdgsagdsgsadgasdg
.
Step 2. Create a data source
Now, create a data source to embed and synchronize it with your AI Workspace.
You can do this by sending a request to either the POST api/v1/datasets/{datasetId}/datasources
endpoint or the POST /v1/datasources
endpoint.
The example below demonstrates the use of the POST /v1/datasources
endpoint.
When making a request:
- Replace
<api-key>
with your actual API key. - Set
fileKey
to your actual one.
Obtain the id
(data source ID) and datasetId
(dataset ID) for later use. In this example, the data source ID is datasource-cadsgfsdagasgadsg
and the dataset ID is dataset-dagasdgasgasg
.
Step 3. Check data source status
The data source must be in the synched state to be ready for use. To check its status, use the GET v1/datasets/{datasetId}/datasources/{datasourceId}
endpoint.
Here’s an example:
Check the status in the response:
In this example, the data source is in the synched
state and is ready for use in data analysis jobs.
Other possible statuses include:
pending
: Waiting to be processed.running
: Currently being processed.error
: Processing failed.
If the status is pending
or running
, wait for some time and check again until it changes to synched
.
If the status is error
, you’ll need to re-upload the file by starting from Step 1.