Problem description
A form field in the PostObject request does not satisfy the matching conditions defined in the policy field.
Causes
When you upload an object using PostObject, OSS validates each form field in the request body against the conditions array in the policy field. If any form field fails its condition, OSS returns an AccessDenied error.
Examples
The following policy requires the success_action_status form field to equal 200:
{
"expiration": "2023-02-19T13:19:00.000Z",
"conditions": [
["eq", "success_action_status", "200"]
]
}This condition uses the eq operator, which means success_action_status in the request body must be exactly 200. If the value of the field is not 200, OSS returns an error.
Solutions
Check the Message field in the error response to identify the failing condition:
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>AccessDenied</Code>
<Message>
Invalid according to Policy:
Policy Condition failed:
["eq", "$success_action_status", "200"]
</Message>
<RequestId>63F1D24***4808C1F</RequestId>
<HostId>example-bucket.oss-cn-hangzhou.aliyuncs.com</HostId>
<EC>0006-00000227</EC>
</Error>The Message field shows the exact condition that failed. Update the corresponding form field in your request to satisfy that condition, then retry.
References
For the full
policyfield specification, see Appendix: Policy.To upload objects directly from a web client using form upload, see Add signatures on the client by using JavaScript and upload data to OSS.
For a full list of PostObject errors and fixes, see Errors and troubleshooting methods of PostObject.