0006-00000117

问题描述

PostObject请求中x-oss-forbid-overwrite表单域的值不合法。

问题原因

您发起了PostObject请求上传文件,但是请求体中x-oss-forbid-overwrite表单域的值不合法,导致请求报错。

问题示例

以下请求体中x-oss-forbid-overwrite表单域的值为abc,与接口要求的该表单域的取值只能为true或者false不相符,导致请求错误。

POST / HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Content-Length: 6443500495
Date: Sat, 18 Feb 2023 05:17:02 GMT
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryW0DET1iaBMeAOBg3
Host: example-bucket.oss-cn-hangzhou.aliyuncs.com
------WebKitFormBoundaryW0DET1iaBMeAOBg3
Content-Disposition: form-data; name="key"
big.img
------WebKitFormBoundaryW0DET1iaBMeAOBg3
Content-Disposition: form-data; name="x-oss-forbid-overwrite"
abc
------WebKitFormBoundaryW0DET1iaBMeAOBg3
Content-Disposition: form-data; name="policy"
eyJleHBpcmF0aW9uIjoiMjAyMy0wMi0xOFQxMzoxOTowMC4wMDBaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTA0ODU3NjAwMF1dfQ==
------WebKitFormBoundaryW0DET1iaBMeAOBg3
Content-Disposition: form-data; name="AWSAccessKeyId"
LTAI5tMw****
------WebKitFormBoundaryW0DET1iaBMeAOBg3
Content-Disposition: form-data; name="success_action_status"
200
------WebKitFormBoundaryW0DET1iaBMeAOBg3
Content-Disposition: form-data; name="signature"
miAoLVohS5*****WEXyC3wVecaQ=
------WebKitFormBoundaryW0DET1iaBMeAOBg3
Content-Disposition: form-data; name="file"; filename="big.img"
Content-Type: application/octet-stream
***
------WebKitFormBoundaryW0DET1iaBMeAOBg3--

解决方案

确保请求体中x-oss-forbid-overwrite表单域的值合法。该表单域用于指定PostObject操作时是否覆盖同名Object。

  • 不指定x-oss-forbid-overwrite或者x-oss-forbid-overwrite取值为false时,表示允许覆盖同名Object。

  • 指定x-oss-forbid-overwritetrue时,表示禁止覆盖同名Object。

相关文档