Download a raw workspace file¶
Download original file bytes, optionally enforcing a full-file size limit or reading a prefix.
GET https://api.moi.matrixorigin.cn/v5/workspaces/{id}/files/{file_id}/download
Before you call this API¶
Set BASE_URL to the product API prefix https://api.moi.matrixorigin.cn/v5; use the corresponding product API URL for a dedicated deployment.
Prepare a personal access token for the target workspace. WORKSPACE_ID must match the path workspace; FILE_ID comes from actual file results. BASE_URL includes the product prefix in the same environment. Example files/IDs are placeholders.
Request parameters¶
curl --fail-with-body -sS -X GET "$BASE_URL/workspaces/$WORKSPACE_ID/files/$FILE_ID/download" \
-H "X-API-Key: $MOI_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-o "$OUTPUT_FILE"
Set MAX_BYTES to positive integer bytes, then choose either a full-file limit or prefix read.
curl --fail-with-body -sS "$BASE_URL/workspaces/$WORKSPACE_ID/files/$FILE_ID/download" \
-H "X-API-Key: $MOI_KEY" -H "X-Workspace-ID: $WORKSPACE_ID" \
-H "X-MOI-Max-Download-Bytes: $MAX_BYTES" \
-o "$OUTPUT_FILE"
curl --fail-with-body -sS "$BASE_URL/workspaces/$WORKSPACE_ID/files/$FILE_ID/download" \
-H "X-API-Key: $MOI_KEY" -H "X-Workspace-ID: $WORKSPACE_ID" \
-H "X-MOI-Download-Prefix-Bytes: $MAX_BYTES" \
-o "$OUTPUT_FILE"
Field |
Type |
Required |
Description |
|---|---|---|---|
|
integer |
No |
Positive integer header. Rejects oversized files before reading. |
|
integer |
No |
Positive integer header. Returns at most this many prefix bytes. |
The two headers are mutually exclusive. Content-Length counts bytes in this response; a prefix is not the complete file. zip uses application/zip, other files application/octet-stream. Attachment filenames encode the original name.
Successful response¶
sample
The response is a byte stream. Consume and close it, and check read/exit status before using the file. Failure after the response starts may interrupt the connection.
Error responses¶
{
"code": 2,
"message": "示例错误信息"
}
Invalid byte limits or conflicting limits return 400/2 with details.reason. Errors use numeric code/message. Oversize returns 413/14 with reason=DOWNLOAD_LIMIT_EXCEEDED, file_size, and limit. Missing/denied/unavailable external sources return 404/3, 403/5, and 503/15, with reasons SOURCE_OBJECT_NOT_FOUND, SOURCE_OBJECT_ACCESS_DENIED, and SOURCE_OBJECT_UNAVAILABLE, plus domain/file_id.