文件上传接口

最近更新时间:2023-07-25


接口名称:upload接口url:https://upload-ess.xycloud.com/upload描述:upload 用于文件上传字段传递方式:参数方式传递

请求参数

名称类型是否必须描述
bucketstringYes用户自己创建的存储 bucket,缺失时返回 403
filesizeintYes上传文件大小,缺失时返回 403
uristringYes文件的唯一标识(重复则覆盖),格式为 test.com/dir/test.txt
,注意开始位置不带'/'
expiretimeintYes期望上传文件在 ESS 存储中保存的过期时间
signstringYes用户 token 值,生成规则:MD5(ak + sk + ct + bucket + filesize + uri + expirestime + mcheck)
akstringYes用户创建时返回的 ak/sk ,用于 token 验证
mcheckstringYes文件内容 md5,用于计算内容是否正确

返回参数

名称类型是否必须描述
errnoint状态码:0 正常,非 0 异常
errmsgstring错误信息:OK/错误原因

示例

请求示例

POST /upload?bucket=bucket&filesize=35&uri=/test.com/dir/test.txt&expiretime=0&sign=6b883e99c162b33221c2f696518fbf59&mcheck=1ca423592943cc8bde88c2fe7d8031e0&ct=1537349037&ak=ak HTTP/1.1 Host: upload-ess.xycloud.com Connection: keep-alive Accept-Encoding: gzip, deflate Accept: */* User-Agent: python-requests/2.19.1 Content-Length: 179 Content-Type: multipart/form-data; boundary=d6814940f7b027bad63253ec4fd30b08 --d6814940f7b027bad63253ec4fd30b08 Content-Disposition: form-data; name="file"; filename="test.txt" sdvfdbshobhrdngbndfbsndfbihrtdnvsh --d6814940f7b027bad63253ec4fd30b08--

返回示例

HTTP/1.1 200 OK Server: openresty Date: Wed, 19 Seq 2018 09:23:53 GMT Content-Type: text/plain Connection: keep-alive Access-Control-Allow-Methods: GET,POST,OPTIONS,HEAD Access-Control-Allow-Credentials: true Access-Control-Allow-Headers: * Access-Control-Allow-Origin: * Content-Length: 26 {"errno":0, "errmsg":"OK"}