Upload files¶
Upload a local file and get a temporary file ID that can be previewed, downloaded, or used for subsequent imports. Uploading only saves temporary files and does not start the import task.
POST https://moi.matrixorigin.cn/newmoi/connectors/file/upload
Preparation before calling¶
Use multipart/form-data request. The current public contract does not define a maximum file size limit for a single upload. Prepare a personal access token and target workspace ID that has access to the target workspace.
The example below uses:
$AI_STUDIO_API_KEY: The actual personal access token, passed through theX-API-KeyHeader.$WORKSPACE_ID: The workspace ID of the file to be uploaded, passed through theX-Workspace-IDHeader.
Request example¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/connectors/file/upload" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-F 'files=@./data.csv'
Form fields¶
Field |
Type |
Is it required |
Description |
|---|---|---|---|
|
file[] |
No |
One or more files to upload. It is recommended to use |
[] after a type denotes an array. [] in a field path denotes each item in an array.
Successful response¶
Returns 200 on success.
{
"code": "OK",
"msg": "OK",
"data": {
"conn_file_ids": ["conn_file_01"],
"file_ids": ["file_01"]
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
string[] or null |
Temporary connector file IDs, returned in the order of uploaded files. |
|
string[] |
Stores file IDs, corresponding to |
In field paths, [] means each item in an array. For example, items[].name is the name field of each item in items.
Error response¶
{
"code": "ErrParamInvalid",
"msg": "invalid multipart form",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
Invalid multipart request. |
Check the form format and file content and try again. |
|
|
The access token is invalid or has expired. |
Try again after updating the access token. |
|
|
The caller does not have permission to upload files in this workspace. |
Check workspace ID and access permissions. |
|
|
The service is temporarily unable to store temporary files. |
Keep the desensitization error message and try again. |
Follow-up operations¶
Save the returned data.conn_file_ids. When you need to view the content, preview file; when you need to take out the file, download file. After confirming that it is useless, delete the file.