Problem description
An invalid value is specified for a content-length-range condition in the policy form field of a PostObject request.
Causes
The content-length-range condition in the conditions array contains a string value (for example, "test") instead of a positive integer. OSS cannot parse the policy JSON and returns an error.
Examples
The following policy fails because max-len is set to the string "test" instead of an integer:
{
"expiration": "2023-02-19T13:19:00.000Z",
"conditions": [
["content-length-range", [1], "test"]
]
}Solutions
Set both min-len and max-len to positive integers. The required format is:
["content-length-range", min-len, max-len]| Field | Type | Description | Constraint |
|---|---|---|---|
min-len | int | Minimum allowed object size, in bytes | Must be a positive integer |
max-len | int | Maximum allowed object size, in bytes | Must be a positive integer; must be >= min-len |
The following example allows uploads between 1 byte and 1,024 bytes:
{
"expiration": "2023-02-19T13:19:00.000Z",
"conditions": [
["content-length-range", 1, 1024]
]
}References
For the full
policyform field specification, see Appendix: Policy.To implement form upload with client-side signing, see Add signatures on the client by using JavaScript and upload data to OSS.
For other PostObject errors, see Errors and troubleshooting methods of PostObject.