Skip to content

查询临时文件上传状态 ​

用 file_key 查询上传状态。只有 state=temporary_available 的文件才能在建码或修改时以 file_key 引用;failed 按 error_code 处理,expired 需重新申请上传。

请求 ​

text
POST https://open.cli.im/api/v2/rpc/assets/getUpload
项目要求
最低权限读写,见权限档位
需要的 scopeassets.write
组织 Key不能调用,返回 403 credential_type_not_allowed,见历史组织 Key

相关调用流程:按模板批量建码。

请求参数 ​

请求体为 JSON。

字段类型必填说明
file_keystring否assets/requestUpload 返回的 file_key。最长 512 个字符
asset_idstring否旧版文件标识,仅为兼容保留;新调用请传 file_key。最长 128 个字符

请求示例 ​

示例里的 ID、幂等键等换成实际值。

bash
curl -sS -X POST 'https://open.cli.im/api/v2/rpc/assets/getUpload' \
  -H "Authorization: Bearer ${CAOLIAO_API_KEY}" \
  -H 'Content-Type: application/json' \
  -d '{
  "file_key": "free/2026/11/18/3f9a1c7e5b2d4a6c8e0f.jpg"
}'

响应 ​

成功时 HTTP 状态码为 200,顶层 code 为 0,结果在 data 里。失败时的返回见错误码与调用额度和业务错误码。

字段类型一定返回说明
data.file_keystring是文件引用,建码和修改时填在图片、附件字段里
data.statestring是uploading 等待上传或处理中;temporary_available 已可引用;failed 失败;expired 已过期。可选值:uploading、temporary_available、failed、expired
data.expires_atinteger否临时文件的过期时间(Unix 秒);被建码或修改引用并保存后转为永久文件
data.upload_expires_atinteger否上传地址的过期时间(Unix 秒)
data.file_namestring否文件名
data.mime_typestring否文件 MIME 类型
data.sizeinteger否文件大小(字节)
data.error_codestring否state 为 failed 或 expired 时的原因码
data.uploadobject否上传方式,state 为 uploading 且文件尚未上传时返回
data.upload.methodstring是固定为 PUT
data.upload.urlstring是带签名的上传地址。含临时凭证,不要记录或展示
data.upload.headersobject是上传时必须原样带上的请求头

响应示例 ​

json
{
  "code": 0,
  "message": "ok",
  "data": {
    "file_key": "free/2026/11/18/3f9a1c7e5b2d4a6c8e0f.jpg",
    "state": "temporary_available",
    "file_name": "compressor.jpg",
    "mime_type": "image/jpeg",
    "size": 204800,
    "expires_at": 1795003600
  }
}

常见错误 ​

ASSET_NOT_FOUND。含义和处理方式见业务错误码。


本页由 openapi.json 生成。全部接口见接口清单。