0034-00000007

更新时间:
复制 MD 格式

Problem description

The MaxAgeSeconds parameter in the XML configuration for cross-origin resource sharing (CORS) is invalid.

Causes

You called the PutBucketCors operation to configure CORS rules for a bucket. The error occurs because a rule in your submitted XML configuration contains an invalid MaxAgeSeconds parameter. The parameter is considered invalid if it appears more than once in the same <CORSRule> tag, or if its value is not a positive integer.

Examples

For example, you send the following request:

PUT /?cors HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Content-Length: 186
Date: Fri, 04 May 2012 03:21:12 GMT
Authorization: OSS qn6q**************:77Dv****************
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration>
    <CORSRule>
      <AllowedOrigin>*</AllowedOrigin>
      <AllowedMethod>PUT</AllowedMethod>
      <AllowedHeader>Authorization</AllowedHeader>
      <MaxAgeSeconds>-1</MaxAgeSeconds>
    </CORSRule>
    <ResponseVary>true</ResponseVary>
</CORSConfiguration>

The MaxAgeSeconds parameter specifies the duration, in seconds, for which a browser can cache the response to a preflight (OPTIONS) request for a specific resource. The value must be a positive integer. In the preceding XML configuration, the value of the MaxAgeSeconds node is -1. This value is invalid and causes the error.

Solutions

Ensure that the XML configuration you submit in the PutBucketCors request is valid. In each <CORSRule> tag, specify the MaxAgeSeconds node only once and set its value to a positive integer.

PUT /?cors HTTP/1.1
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Content-Length: 186
Date: Fri, 04 May 2012 03:21:12 GMT
Authorization: OSS qn6q**************:77Dv****************
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration>
    <CORSRule>
      <AllowedOrigin>*</AllowedOrigin>
      <AllowedMethod>PUT</AllowedMethod>
      <AllowedMethod>GET</AllowedMethod>
      <AllowedHeader>Authorization</AllowedHeader>
      <MaxAgeSeconds>100</MaxAgeSeconds>
    </CORSRule>
    <ResponseVary>false</ResponseVary>
</CORSConfiguration>

References