Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get aws bucket content listing using Postman - "Get Bucket (Version 2)" RestAPI

I am using Postman to send the AWS S3 RestAPI "Get Bucket (Version 2)" to get bucket listing.

Name of bucket is "test-bucket-1.ahadomain.com" (ahadomain.com is a dummy nonexistent domain that I used when naming the bucket in aws). The user credentials I am using has all the permissions to make S3 calls. I am following the info on page - http://docs.aws.amazon.com/AmazonS3/latest/API/v2-RESTBucketGET.html

I am using the endpoint : https://test-bucket-1.s3.us-east-1.amazonaws.com I am sending the following Headers : Content-Type, Host, X-Amz-Content-Sha256, X-Amz-Date, Authorization

Do I need to add "list-type" as a query parameter or as a header? If as a query parameter, how do I state it in the url.

I am getting the following response, which does not contain a listing of the content, just info about the bucket itself:

<?xml version="1.0" encoding="UTF-8"?>
<ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <Owner>
        <ID>6893100ea2b48696e8ccc3aa17414f4325cf59b574474ad9de0bcb0d139590c9</ID>
        <DisplayName>ahmedsmail</DisplayName>
    </Owner>
    <Buckets>
        <Bucket>
            <Name>test-bucket-1.ahadomain.com</Name>
            <CreationDate>2017-09-06T06:36:15.000Z</CreationDate>
        </Bucket>
    </Buckets>
</ListAllMyBucketsResult>

Any help would be greatly appreciated.

Thank you, Ahmed.

like image 512
Ahmed A Avatar asked Sep 13 '17 19:09

Ahmed A


1 Answers

You can do the following:

  1. Set the method to GET
  2. in the URL: https://s3.amazonaws.com/test-bucket-1.ahadomain.com/?list-type=2
    Note: If the region of your bucket is not in us-east-1, change the s3.amazonaws.com to correct S3 endpoint of that region.
  3. In Authorization tab, set the following:
    a. Type: AWS Signature
    b. AccessKey:
    c. SecretKey:
    d. AWS Region: us-east-1
    Note: change this if this is not the region of your bucket
    e. Service Name: s3
    f. Check "Save helper data to request"
  4. Go to Headers tab, delete all entries if there is any.
  5. Then click "Send" button

Here sample result

like image 62
Rodel Avatar answered Oct 02 '22 07:10

Rodel