Problem description
A PostObject request fails when a parameter in the conditions array of the policy form field has an incorrect data type.
Causes
A PostObject request fails because a parameter for an operator in the conditions array of the policy has an incorrect data type.
Example
A request error occurs in the following example because the not-in operator, which requires the data type of the second parameter to be a list, is used with the string "no-cache".
{
"expiration": "2023-02-19T13:19:00.000Z",
"conditions": [
["not-in", "cache-control", "no-cache"]
]
}Solution
The following example shows a policy with correctly configured conditions for various 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 more information about
policy, see Appendix: Policy.For an example of uploading objects to OSS from a web client using form upload, see Add signatures on the client by using JavaScript and upload data to OSS.
To learn about common PostObject errors and how to fix them, see common PostObject errors.