0006-00000204

Updated at:

Error 0006-00000204 indicates that the policy form field of a PostObject request fails validation. This topic describes why the validation fails and how to build and encode a valid value for the field.

Problem description

The value of the policy form field in the PostObject request is not a valid JSON structure.

Causes

OSS decodes the value of the policy form field in Base64 and then validates the decoded value as JSON. If the decoded value is not a valid JSON structure, the PostObject request fails.

Solutions

Generate the value of the policy form field in the following order:

  1. Write the value as a valid JSON structure. For more information about the policy form field, see Appendix: Policy.

  2. Encode the JSON structure in UTF-8.

  3. Encode the UTF-8 encoded value in Base64, and use the result as the value of the policy form field.

The following example shows a valid policy structure. Replace the example values, including the expiration value, with the values that apply to your request.

{
  "expiration": "2014-12-01T12:00:00.000Z",
  "conditions": [
    {"bucket": "johnsmith"},
    ["content-length-range", 1, 10],
    ["eq", "$success_action_status", "201"],
    ["starts-with", "$key", "user/eric/"],
    ["in", "$content-type", ["image/jpeg", "image/png"]],
    ["not-in", "$cache-control", ["no-cache"]]
  ]
}

If the conditions list in the request contains the content-length-range condition, the minimum and the maximum allowed sizes of the object that you want to upload must both be positive integers, as in ["content-length-range", 1, 10].

References