0006-00000223

更新时间:
复制 MD 格式

Problem description

An invalid value is specified for a content-length-range condition in the policy form field of a PostObject request.

Causes

The content-length-range condition in the conditions array contains a string value (for example, "test") instead of a positive integer. OSS cannot parse the policy JSON and returns an error.

Examples

The following policy fails because max-len is set to the string "test" instead of an integer:

{
    "expiration": "2023-02-19T13:19:00.000Z",
    "conditions": [
        ["content-length-range", [1], "test"]
    ]
}

Solutions

Set both min-len and max-len to positive integers. The required format is:

["content-length-range", min-len, max-len]
FieldTypeDescriptionConstraint
min-lenintMinimum allowed object size, in bytesMust be a positive integer
max-lenintMaximum allowed object size, in bytesMust be a positive integer; must be >= min-len

The following example allows uploads between 1 byte and 1,024 bytes:

{
    "expiration": "2023-02-19T13:19:00.000Z",
    "conditions": [
        ["content-length-range", 1, 1024]
    ]
}

References