0006-00000222

更新时间:
复制 MD 格式

Problem description

A conditions item in the PostObject policy is not a map or list.

Causes

The PostObject operation requires every item in the conditions array of the policy form field to be either a map (JSON object) or a list (JSON array). If any item is a primitive value such as an integer, OSS rejects the request and returns an error.

Examples

In the following policy, the first conditions item is 123, which is an integer — not a map or list:

{
    "expiration": "2023-02-19T13:19:00.000Z",
    "conditions": [
        123,                                    // Invalid: integer, not a map or list
        ["content-length-range", 10, 1024]
    ]
}

Solutions

Replace every conditions item with a valid map or list. The following table shows the three valid condition formats:

FormatSyntaxDescription
Map (exact match){"field": "value"}The field value must exactly match the specified value
List (operator match)["operator", "$field", "value"]The field value must satisfy the operator condition
List (range match)["content-length-range", min, max]The object size must fall within the specified range

The following policy shows a valid conditions array:

{
    "expiration": "2023-02-19T13:19:00.000Z",
    "conditions": [
        ["content-length-range", 1, 1024],              // Object size must be between 1 and 1024 bytes
        ["eq", "$success_action_status", "201"],         // Return HTTP 201 on success
        ["starts-with", "$key", "user/eric/"],           // Object key must start with user/eric/
        ["in", "$content-type", ["image/jpg", "image/png"]],   // Content type must be JPEG or PNG
        ["not-in", "$cache-control", ["no-cache"]]       // Cache-Control must not be no-cache
    ]
}

References