Problem description
The expiration value in the PostObject policy is not a valid ISO 8601 datetime string.
Causes
OSS validates the expiration field when processing a PostObject request. The value must be an ISO 8601 datetime string in GMT, using the T separator between date and time and the Z suffix to indicate UTC. A plain datetime string without these elements fails validation.
Examples
The following policy triggers the error because expiration uses a space instead of T as the date-time separator, and omits the Z suffix:
{
"expiration": "2023-02-19 13:19:00",
"conditions": [
["content-length-range", 0, 1048576000]
]
}Solutions
Set expiration to a valid ISO 8601 datetime string in the format YYYY-MM-DDTHH:mm:ss.sssZ:
{
"expiration": "2023-02-19T13:19:00.000Z",
"conditions": [
["content-length-range", 0, 1048576000]
]
}The following table shows the differences between the invalid and valid formats:
| Element | Invalid | Valid | Description |
|---|---|---|---|
| Date-time separator | space | T | ISO 8601 requires T between date and time |
| Timezone | (absent) | Z | Z denotes UTC (equivalent to GMT+0) |
| Milliseconds | (absent) | .000 | Optional but recommended for clarity |
The expiration field specifies when the policy expires, not when the uploaded object expires. Set it to a future time relative to when your client generates the policy.References
For the full policy field specification, see Appendix: Policy.
For a complete example of client-side form upload with JavaScript, see Add signatures on the client by using JavaScript and upload data to OSS.
For other PostObject errors and fixes, see Errors and troubleshooting methods of PostObject.