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.

HTTP
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

Shell
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.

Shell
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

file (array of files)

Yes

Local file. Repeat this form field to upload multiple files.

VolumeID

string

Yes

Target volume ID.

meta

string

No

A JSON string consisting of the source file name and path.

meta.filename

string

No

File name matching the corresponding file part.

meta.path

string

No

Relative source path of the file.

path_regex

string

No

Regular expression to filter meta.path.

unzip_keep_structure

string

No

Whether to preserve the directory structure when decompressing.

dedup

string

No

JSON string for duplicate file handling settings.

dedup.by

array of string

No

Duplicate file judgment field.

dedup.strategy

string

No

Duplicate file handling policy.

Import structured files into a table

Parameter

Type

Required

Description

meta

string

Yes

A JSON string of structured filenames and paths.

table_config

string

Yes

A JSON string consisting of the target table and column mapping.

table_config.new_table

boolean

Yes

false means using an existing table. When set to true, use database_id and create_table to create a new table. Use multi_sheet and tables for XLS or XLSX multiple worksheets instead, and do not mix them with single-table field siblings.

table_config.table_id

integer

Yes

Target table ID already exists.

table_config.conn_file_ids

array of string

Yes

Temporary file ID returned by the upload interface.

table_config.isColumnName

boolean

Yes

Whether to use the specified row as a column name.

table_config.columnNameRow

integer

Yes

The row where the column name is located starts from 1.

table_config.rowStart

integer

Yes

The data starts from 1.

table_config.csv

object

No

CSV parsing settings.

table_config.csv.separator

string

No

CSV column separator.

table_config.existed_table

array of object

Yes

Mapping of file columns to target columns.

table_config.existed_table[].tableColumn

string

No

Target table column name.

table_config.existed_table[].column

string

No

Column names in the file.

table_config.existed_table[].col_num_in_file

integer

No

Column number in the file.

Successful response

JSON
{
  "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

code

string

OK on success.

msg

string

OK on success.

data.task_id

string

Created import task ID.

data.file_ids

array of string

The file ID successfully processed this time. The structured temporary file process may be empty.

data.success

boolean

Whether the request was created successfully.

data.message

string

Description of processing results.

data.results

array of object

Results returned by file.

data.results[].success

boolean

Whether the file was successfully processed.

data.results[].message

string

Description of the processing results of this file.

data.acceptance_status

string

Document acceptance status.

data.file_id

string

Associated file ID. Returns if present.

data.results[].filename

string

This file name.

Error response

JSON
{
  "code": "ErrParamInvalid",
  "msg": "invalid upload parameters",
  "data": null
}

Field

Type

Description

code

string

error code.

msg

string

Readable error message.

data

null

The error response is null.

Last updated on