0014-00000085

Updated at:

Problem description

The request body of a PutBucketLifecycle request contains multiple rules that specify the same prefix.

Causes

A PutBucketLifecycle request fails if its request body contains multiple rules that specify the same prefix.

Example Problem

The following example shows a PutBucketLifecycle request that specifies two rules.

  • The first rule specifies the prefix test and deletes matching objects 200 days after they are last modified.

  • The second rule also specifies the prefix test and transforms matching objects to the Infrequent Access (IA) storage class 100 days after they are last modified.

The request fails because both rules specify the same prefix.

PUT /?lifecycle HTTP/1.1
Host: oss-example.oss.aliyuncs.com
Content-Length: 336
Date: Mon , 6 May 2019 15:23:20 GMT
Authorization: OSSqn6q**************:77Dv****************
<?xml version="1.0" encoding="UTF-8"?>
<LifecycleConfiguration>
  <Rule>
    <ID>rule1</ID>
    <Prefix>test</Prefix>
    <Status>Enabled</Status>
    <Expiration>
    	<Days>200</Days>
    </Expiration>
  </Rule>
  <Rule>
    <ID>rule2</ID>
    <Prefix>test</Prefix>
    <Status>Enabled</Status>
    <Transition>
    	<Days>100</Days>
      <StorageClass>IA</StorageClass>
    </Transition>
  </Rule>
</LifecycleConfiguration>

Solutions

  • To configure multiple lifecycle rules, ensure that the value of the Prefix node is unique for each rule.

    PUT /?lifecycle HTTP/1.1
    Host: oss-example.oss-cn-hangzhou.aliyuncs.com
    Content-Length: 336
    Date: Mon , 6 May 2019 15:23:20 GMT
    Authorization: OSS qn6q**************:77Dv****************
    <?xml version="1.0" encoding="UTF-8"?>
    <LifecycleConfiguration>
      <Rule>
        <ID>rule1</ID>
        <Prefix>test</Prefix>
        <Status>Enabled</Status>
        <Expiration>
        	<Days>200</Days>
        </Expiration>
      </Rule>
      <Rule>
        <ID>rule2</ID>
        <Prefix>log</Prefix>
        <Status>Enabled</Status>
        <Transition>
        	<Days>100</Days>
          <StorageClass>IA</StorageClass>
        </Transition>
      </Rule>
    </LifecycleConfiguration>
  • You can configure lifecycle rules in the OSS console to avoid manually creating the request body.

References