Problem description
A PostObject request fails because the uploaded object exceeds the allowed size.
Causes
Hard limit exceeded: The object is larger than 5 GB. PostObject does not support objects larger than 5 GB.
Policy condition violated: The policy field contains a
content-length-rangecondition, and the object size falls outside the specified range.
Examples
The following request fails because big.img has a Content-Length of 6443500495, which exceeds the 5 GB limit. The Base64-decoded policy also sets content-length-range to a maximum of 1048576000 bytes (approximately 1 GB).
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="name"
big.img
------WebKitFormBoundaryW0DET1iaBMeAOBg3
Content-Disposition: form-data; name="key"
${filename}
------WebKitFormBoundaryW0DET1iaBMeAOBg3
Content-Disposition: form-data; name="policy"
eyJleHBpcmF0aW9uIjoiMjAyMy0wMi0xOFQxMzoxOTowMC4wMDBaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTA0ODU3NjAwMF1dfQ==
------WebKitFormBoundaryW0DET1iaBMeAOBg3
Content-Disposition: form-data; name="OSSAccessKeyId"
LTAI****************
------WebKitFormBoundaryW0DET1iaBMeAOBg3
Content-Disposition: form-data; name="success_action_status"
200
------WebKitFormBoundaryW0DET1iaBMeAOBg3
Content-Disposition: form-data; name="signature"
miAo****************
------WebKitFormBoundaryW0DET1iaBMeAOBg3
Content-Disposition: form-data; name="file"; filename="big.img"
Content-Type: application/octet-stream
***
------WebKitFormBoundaryW0DET1iaBMeAOBg3--Solutions
Hard limit exceeded: Make sure the object is no larger than 5 GB before uploading via PostObject.
Policy condition violated: If the policy field contains a
content-length-rangecondition, make sure the object size falls within the specified range. Thecontent-length-rangecondition uses the following format, where values are in bytes:["content-length-range", <min-bytes>, <max-bytes>]For example, to allow objects between 1 MiB and 10 MiB:
["content-length-range", 1048576, 10485760]The policy field is a UTF-8 and Base64-encoded JSON string. To check the effective range, decode the
policyform field value and inspect theconditionsarray.
References
PostObject — full API reference for the PostObject operation
Add signatures on the client by using JavaScript and upload data to OSS — how to implement form upload from a web client
Errors and troubleshooting methods of PostObject — other common PostObject errors and fixes