Download file¶
Download file contents.
POST $CLOUDSIGMA_API_BASE/catalog/file/download
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. First query the file list to obtain the target file ID. Prepare the personal access token, target workspace ID, and file ID that can access the target workspace.
The file must be mounted and the root volume to which it belongs can be determined. Files that are not mounted or belong to multiple root volumes may not be downloaded. Passing in volume_id also cannot bypass this restriction.
Request body¶
curl -X POST "$CLOUDSIGMA_API_BASE/catalog/file/download" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"file_id": "'"$FILE_ID"'"
}' \
-o ./downloaded-file
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
File ID, cannot be empty. |
|
string |
No |
Currently does not participate in this interface processing. Permissions are verified against the actual root volume corresponding to file_id. |
|
boolean |
No |
Whether to download as ZIP. |
Successful response¶
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: inline 或 attachment
[文件内容]
Field |
Type |
Description |
|---|---|---|
|
HTTP status |
|
|
HTTP Header |
File MIME type. |
|
HTTP Header |
Download attachment when filename is available. |
|
binary |
File content. |
Error response¶
When the download fails before it starts, an error message in JSON format is returned:
{
"code": "ErrParamInvalid",
"msg": "file_id 不能为空"
}
Field |
Type |
Description |
|---|---|---|
|
string |
error code. |
|
string |
error message. |