Upload a workspace file record

Upload a workspace file record without associating it with a volume.

POST https://api.moi.matrixorigin.cn/v5/workspaces/{id}/files

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 POST "$BASE_URL/workspaces/$WORKSPACE_ID/files" \
  -H "X-API-Key: $MOI_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -F "file=@$UPLOAD_FILE;type=text/plain" \
  -F "initial_ref_count=0"

Field

Type

Required

Description

file

file

Yes

Multipart file.

initial_ref_count

integer

No

Initial reference count, default 0, range 0–2147483647.

Success uses HTTP 201 and numeric code=0. Uploading alone neither creates a volume association nor publishes an agent artifact. Positive reference counts affect deletion.

Successful response

{
  "code": 0,
  "data": {
    "file_id": "file-example",
    "original_name": "sample.txt",
    "size": 7,
    "md5": "5177a58dc65c8a14dc90c69db3bf3dd2"
  }
}

Success uses numeric code=0; data contains file_id, original_name, size, and md5. No msg field.

Error responses

{
  "code": 2,
  "message": "示例错误信息"
}

Invalid request fields return 400/2. Business upload failures use numeric code/message. Internal write failures may return 500/1.

Last updated on