Delete files¶
Delete temporary files, which cannot be recovered after deletion.
POST https://moi.matrixorigin.cn/newmoi/connectors/file/delete
Preparation before calling¶
Prepare a personal access token that has access to the target workspace, the target workspace ID, and the temporary file ID. Make sure the file is no longer needed before deleting it.
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 deleted, passed through theX-Workspace-IDHeader.$CONN_FILE_ID: Temporary file ID to delete, passed viaconn_file_id.
Request example¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/connectors/file/delete" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d "{
\"conn_file_id\": \"$CONN_FILE_ID\"
}"
Request body¶
Field |
Type |
Is it required |
Description |
|---|---|---|---|
|
string |
Yes |
The ID of the temporary file to be deleted. |
Successful response¶
Returns 200 on success and data is null.
{
"code": "OK",
"msg": "OK",
"data": null
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
null |
This interface does not return metadata of deleted files. |
Error response¶
{
"code": "ErrParamInvalid",
"msg": "invalid file identifier",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
The JSON request body is invalid. |
Check the JSON format and try again. |
|
|
|
Confirm the file ID; no need to delete the file again if it has already been deleted. |
|
|
The access token is invalid or has expired. |
Try again after updating the access token. |
|
|
The caller does not have permission to delete temporary files. |
Check workspace ID and access permissions. |
|
|
The service is temporarily unable to delete files. |
Keep the desensitization error message and try again. |
Follow-up operations¶
When you need to confirm the deletion result, keep conn_file_id and Preview file or Download file again. Both interfaces return a non-exist error when the temporary file has been deleted.