Problem description
The value of the content-length-range condition in the Post policy is invalid.
Causes
When you send a PostObject request to upload a file, a content-length-range error can occur for either of these reasons:
Incorrect `content-length-range` value: The
content-length-rangecondition in a Post policy must follow this format:["content-length-range", min-len, max-len]Both
min-lenandmax-lenmust be positive integers, andmax-lenmust be greater than or equal tomin-len. Passing a string, a negative number, or swapping the order causes the request to fail.Clock skew between the client and the OSS server: A PostObject request includes time-related fields —
x-oss-datein the request header andexpirationin the policy. OSS rejects any request where the difference between the client timestamp and the server time exceeds 15 minutes. When this happens, OSS returns a policy-related error even if thecontent-length-rangevalue itself is correct.
Examples
Example 1: Incorrect `content-length-range` value
In the following Post policy, min-len is incorrectly set to the string "test" instead of an integer, which makes the value invalid:
{
"expiration": "2023-02-19T13:19:00.000Z",
"conditions": [
["content-length-range", "test", 10]
]
}Example 2: Clock skew between the client and the OSS server
The policy itself is correctly configured, but the request is rejected because the client time (8:00 AM) differs from the OSS server time (3:00 PM) by more than 15 minutes. As a result, the expiration field in the policy has either already expired or has not yet become valid.
Solutions
Correct the `content-length-range` value: Make sure that
min-lenandmax-lenare positive integers, and thatmax-lenis greater than or equal tomin-len:{ "expiration": "2023-02-19T13:19:00.000Z", "conditions": [ ["content-length-range", 1, 1024] ] }Synchronize the client clock: Use Network Time Protocol (NTP) to synchronize the system clock on the client — whether the client is a backend server or a web browser. Keeping the client clock within 15 minutes of server time prevents signature and policy expiration errors.
References
For more information about the policy form field, see Appendix: Policy.
For information about how to transfer data from the web client to OSS using form upload, see Add signatures on the client using JavaScript and upload data to OSS.
For information about common errors and troubleshooting methods of the PostObject operation, see Errors and troubleshooting methods of PostObject.