0006-00000220

更新时间:
复制 MD 格式

Problem description

The value of the content-length-range condition in the Post policy is invalid.

Causes

When you send a PostObject request to upload a file, a content-length-range error can occur for either of these reasons:

  1. Incorrect `content-length-range` value: The content-length-range condition in a Post policy must follow this format:

       ["content-length-range", min-len, max-len]

    Both min-len and max-len must be positive integers, and max-len must be greater than or equal to min-len. Passing a string, a negative number, or swapping the order causes the request to fail.

  2. Clock skew between the client and the OSS server: A PostObject request includes time-related fields — x-oss-date in the request header and expiration in the policy. OSS rejects any request where the difference between the client timestamp and the server time exceeds 15 minutes. When this happens, OSS returns a policy-related error even if the content-length-range value itself is correct.

Examples

Example 1: Incorrect `content-length-range` value

In the following Post policy, min-len is incorrectly set to the string "test" instead of an integer, which makes the value invalid:

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

Example 2: Clock skew between the client and the OSS server

The policy itself is correctly configured, but the request is rejected because the client time (8:00 AM) differs from the OSS server time (3:00 PM) by more than 15 minutes. As a result, the expiration field in the policy has either already expired or has not yet become valid.

Solutions

  1. Correct the `content-length-range` value: Make sure that min-len and max-len are positive integers, and that max-len is greater than or equal to min-len:

       {
           "expiration": "2023-02-19T13:19:00.000Z",
           "conditions": [
               ["content-length-range", 1, 1024]
           ]
       }
  2. Synchronize the client clock: Use Network Time Protocol (NTP) to synchronize the system clock on the client — whether the client is a backend server or a web browser. Keeping the client clock within 15 minutes of server time prevents signature and policy expiration errors.

References