Create file¶
Associates one or more existing file records to the specified volume.
POST https://moi.matrixorigin.cn/newmoi/catalog/file/create
Preparation before calling¶
First upload the file to obtain the file ID, and query the object in the database to obtain the target volume ID]. Prepare a personal access token, target workspace ID, target volume ID, and file 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: Target workspace ID, passed throughX-Workspace-IDHeader.$VOLUME_ID: Target volume ID.$FILE_ID: The file ID to associate to the volume.
Request example¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/catalog/file/create" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"volume_id": '"$VOLUME_ID"',
"file_ids": ["'"$FILE_ID"'"]
}'
Request body¶
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
integer |
Yes |
Target volume ID. |
|
array[string] |
Yes |
List of file IDs to associate. |
Successful response¶
Returns 200 on success, data is null. This response indicates that the file is associated with the specified volume.
{
"code": "OK",
"msg": "OK",
"data": null
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
null |
Fixed to |
Error response¶
{
"code": "ErrParamInvalid",
"msg": "请求参数无效",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
Invalid request body, volume ID, or file ID. |
Check |
|
|
The current identity does not have write permissions to the target root volume. |
Use credentials with write access, or contact your administrator for authorization. |
|
|
The volume or file does not exist. |
Check volume ID and file ID. |
|
|
The service cannot associate the file. |
Record the request time and error message and try again; if it continues to fail, contact support. |
Follow-up operations¶
Query file list Confirm that the file is associated with the volume.