Upload locally and create an import task¶
Upload local files and create import tasks. Unstructured files are written to the data volume. Data rows for CSV, XLS, and XLSX are written to the target table.
POST $CLOUDSIGMA_API_BASE/connectors/upload
Before you call¶
Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region. Prepare a personal access token, target workspace ID and a destination volume or table accessible in that workspace.
Request body¶
Replace $CLOUDSIGMA_API_KEY, $WORKSPACE_ID, and the resource IDs in the example with actual values. Submit JSON form values as strings.
Upload unstructured files to data volumes
curl -X POST "$CLOUDSIGMA_API_BASE/connectors/upload" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-F 'file=@./manuals/product.pdf' \
-F 'file=@./manuals/guide.docx' \
-F "VolumeID=$VOLUME_ID" \
-F 'meta=[{"filename":"product.pdf","path":"manuals/product.pdf"},{"filename":"guide.docx","path":"manuals/guide.docx"}]' \
-F 'path_regex=^manuals/.*' \
-F 'unzip_keep_structure=false' \
-F 'dedup={"by":["name","md5"],"strategy":"skip"}'
Upload structured files to existing data tables
In this scenario, first upload the file to obtain the temporary file ID, and then fill in the ID into table_config.conn_file_ids. Do not pass file or VolumeID.
curl -X POST "$CLOUDSIGMA_API_BASE/connectors/upload" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-F 'meta=[{"filename":"orders.csv","path":"orders.csv"}]' \
-F 'table_config={
"new_table": false,
"table_id": '"$TARGET_TABLE_ID"',
"conn_file_ids": ["'"$CONN_FILE_ID"'"],
"isColumnName": true,
"columnNameRow": 1,
"rowStart": 2,
"csv": {
"separator": ","
},
"existed_table": [
{
"tableColumn": "'"$TARGET_COLUMN"'",
"column": "'"$FILE_COLUMN"'",
"col_num_in_file": 1
}
]
}'
Unstructured files: Up to 20 files can be uploaded at a time, each file shall not exceed 200 MiB.
Structured files: Upload one file at a time, up to 200 MiB. Supported formats are CSV, XLS, and XLSX.
Upload unstructured files to data volumes
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
file (array of files) |
Yes |
Local file. Repeat this form field to upload multiple files. |
|
string |
Yes |
Target volume ID. |
|
string |
No |
A JSON string consisting of the source file name and path. |
|
string |
No |
File name matching the corresponding |
|
string |
No |
Relative source path of the file. |
|
string |
No |
Regular expression to filter |
|
string |
No |
Whether to preserve the directory structure when decompressing. |
|
string |
No |
JSON string for duplicate file handling settings. |
|
array of string |
No |
Duplicate file judgment field. |
|
string |
No |
Duplicate file handling policy. |
Import structured files into a table
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
A JSON string of structured filenames and paths. |
|
string |
Yes |
A JSON string consisting of the target table and column mapping. |
|
boolean |
Yes |
|
|
integer |
Yes |
Target table ID already exists. |
|
array of string |
Yes |
Temporary file ID returned by the upload interface. |
|
boolean |
Yes |
Whether to use the specified row as a column name. |
|
integer |
Yes |
The row where the column name is located starts from 1. |
|
integer |
Yes |
The data starts from 1. |
|
object |
No |
CSV parsing settings. |
|
string |
No |
CSV column separator. |
|
array of object |
Yes |
Mapping of file columns to target columns. |
|
string |
No |
Target table column name. |
|
string |
No |
Column names in the file. |
|
integer |
No |
Column number in the file. |
Successful response¶
{
"code": "OK",
"msg": "OK",
"data": {
"task_id": "task_01",
"file_ids": [
"file_01"
],
"success": true,
"message": "OK",
"results": [
{
"file_id": "file_01",
"message": "上传成功",
"success": true
}
],
"file_id": "file_01",
"acceptance_status": "accepted"
}
}
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
string |
Created import task ID. |
|
array of string |
The file ID successfully processed this time. The structured temporary file process may be empty. |
|
boolean |
Whether the request was created successfully. |
|
string |
Description of processing results. |
|
array of object |
Results returned by file. |
|
boolean |
Whether the file was successfully processed. |
|
string |
Description of the processing results of this file. |
|
string |
Document acceptance status. |
|
string |
Associated file ID. Returns if present. |
|
string |
This file name. |
Error response¶
{
"code": "ErrParamInvalid",
"msg": "invalid upload parameters",
"data": null
}
Field |
Type |
Description |
|---|---|---|
|
string |
error code. |
|
string |
Readable error message. |
|
null |
The error response is |