Invalid parameter type in PostObject policy conditions
When a PostObject request fails because a matching condition in the Post Policy contains a parameter of the wrong type, the request is rejected. This topic explains why this error occurs and how to correct the parameter types in your policy conditions.
Problem
Your PostObject request to upload an object is rejected. The Post Policy form field contains a matching condition whose parameter does not match the expected data type for that condition operator.
Cause
A Post Policy defines the conditions that a PostObject request must satisfy. Each matching condition in the conditions array is itself an array whose elements must follow specific type rules. When a condition operator receives a parameter of the wrong type, the entire policy is considered invalid and the request fails.
Solution
The following policy corrects the parameter types for all condition operators.
{
"expiration": "2023-02-19T13:19:00.000Z",
"conditions": [
["content-length-range", 1, 1024],
["eq", "$success_action_status", "201"],
["starts-with", "$key", "user/eric/"],
["in", "$content-type", ["image/jpeg", "image/png"]],
["not-in", "$cache-control", ["no-cache"]]
]
}References
For the complete Post Policy specification, see Appendix: Post Policy.
For an example of uploading data to OSS from a web client by using form upload, see Add signatures on the client by using JavaScript and upload data to OSS.
For common PostObject errors and troubleshooting methods, see PostObject errors and troubleshooting.