Create file¶
Associates one or more existing file records to the specified volume.
POST $CLOUDSIGMA_API_BASE/catalog/file/create
Before you call this API¶
Configure the regional API endpoint and authentication, and select the target workspace.
First upload the file to obtain the file ID, and query the object in the database to obtain the target volume ID].
Set the operation-specific values used in the request:
$VOLUME_ID: Target volume ID.$FILE_ID: The file ID to associate to the volume.
Request¶
curl -X POST "$CLOUDSIGMA_API_BASE/catalog/file/create" \
-H "X-API-Key: $CLOUDSIGMA_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.