Deleting multiple objects in a AWS S3 bucket with s3curl.pl?

Posted by user183394 on Server Fault See other posts from Server Fault or by user183394
Published on 2012-04-05T00:55:12Z Indexed on 2012/04/05 5:32 UTC
Read the original article Hit count: 512

I have been trying to use the AWS "official" command line tool s3curl.pl to test out the recently announced multi-object delete. Here is what I have done:

First, I tested out the s3curl.pl with a set of credentials without a hitch:

$ s3curl.pl --id=s3 -- http://testbucket-0.s3.amazonaws.com/|xmllint --format -
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   884    0   884    0     0   4399      0 --:--:-- --:--:-- --:--:--  5703
    <?xml version="1.0" encoding="UTF-8"?>
    <ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
      <Name>testbucket-0</Name>
      <Prefix/>
      <Marker/>
      <MaxKeys>1000</MaxKeys>
      <IsTruncated>false</IsTruncated>
      <Contents>
        <Key>file_1</Key>
        <LastModified>2012-03-22T17:08:17.000Z</LastModified>
        <ETag>"ee0e521a76524034aaa5b331842a8b4e"</ETag>
        <Size>400000</Size>
        <Owner>
          <ID>e6d81ea69572270e58d3814ab674df8c8f1fd5d502669633a4951bdd5185f7f4</ID>
          <DisplayName>zackp</DisplayName>
        </Owner>
        <StorageClass>STANDARD</StorageClass>
      </Contents>
      <Contents>
        <Key>file_2</Key>
        <LastModified>2012-03-22T17:08:19.000Z</LastModified>
        <ETag>"6b32cbf8219a59690a9f69ba6ff3f590"</ETag>
        <Size>600000</Size>
        <Owner>
          <ID>e6d81ea69572270e58d3814ab674df8c8f1fd5d502669633a4951bdd5185f7f4</ID>
          <DisplayName>zackp</DisplayName>
        </Owner>
        <StorageClass>STANDARD</StorageClass>
      </Contents>
    </ListBucketResult>

Then, I following the s3curl.pl's usage instructions:

s3curl.pl --help
Usage /usr/local/bin/s3curl.pl --id friendly-name (or AWSAccessKeyId) [options] -- [curl-options] [URL]
 options:
  --key SecretAccessKey       id/key are AWSAcessKeyId and Secret (unsafe)
  --contentType text/plain    set content-type header
  --acl public-read           use a 'canned' ACL (x-amz-acl header)
  --contentMd5 content_md5    add x-amz-content-md5 header
  --put <filename>            PUT request (from the provided local file)
  --post [<filename>]         POST request (optional local file)
  --copySrc bucket/key        Copy from this source key
  --createBucket [<region>]   create-bucket with optional location constraint
  --head                      HEAD request
  --debug                     enable debug logging
 common curl options:
  -H 'x-amz-acl: public-read' another way of using canned ACLs
  -v                          verbose logging

Then, I tried the following, and always got back error. I would appreciated it very much if someone could point out where I made a mistake?

$ s3curl.pl --id=s3 --post multi_delete.xml -- http://testbucket-0.s3.amazonaws.com/?delete
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message><StringToSignBytes>50 4f 53 54 0a 0a 0a 54 68 75 2c 20 30 35 20 41 70 72 20 32 30 31 32 20 30 30 3a 35 30 3a 30 38 20 2b 30 30 30 30 0a 2f 7a 65 74 74 61 72 2d 74 2f 3f 64 65 6c 65 74 65</StringToSignBytes><RequestId>707FBE0EB4A571A8</RequestId><HostId>mP3ZwlPTcRqARQZd6gU4UvBrxGBNIVa0VVe5p0rqGmq5hM65RprwcG/qcXe+pmDT</HostId><SignatureProvided>edkNGuugiSFe0ku4eGzkh8kYgHw=</SignatureProvided><StringToSign>POST


Thu, 05 Apr 2012 00:50:08 +0000

The file multi_delete.xml contains the following:

cat multi_delete.xml
<?xml version="1.0" encoding="UTF-8"?>
<Delete>
    <Quiet>true</Quiet>
    <Object>
      <Key>file_1</Key>
      <VersionId> </VersionId>>
    </Object>
    <Object>
      <Key>file_2</Key>
      <VersionId> </VersionId>
    </Object>
</Delete>

Thanks for any help!

--Zack

© Server Fault or respective owner

Related posts about amazon-web-services

Related posts about amazon-s3