Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use AWS S3 REST API ListObjects(v2) with multiple parent/child bucket directories?

What am I missing here?

I'm able to list objects no problem using the aws cli and this command:

aws s3 ls s3://bucket.mycompany.com/parent-dir1/parent-dir2/

But using the REST API via Postman, an equivalent request returns an empty response.

  • Tool: Postman
  • Method: GET
  • URl:
    • https://bucket.mycompany.com.s3.amazonaws.com/parent-dir1/parent-dir2/?list-type=2
  • Auth: enter image description here
  • Headers:
    • I've tried with no headers and with x-amz-content-sha256 UNSIGNED-PAYLOAD
    • Message says "This is a duplicate header and will be overridden..." when I try to use this header enter image description here
  • Response:
  • Status 200 but response is empty(There are MANY files in parent-dir2).

enter image description here enter image description here

like image 629
ericOnline Avatar asked Oct 31 '25 05:10

ericOnline


1 Answers

Eureka! Found the answer in the AWS docs here

Winner ended up being:

  • https://bucket.mycompany.com.s3.amazonaws.com/?list-type=2&prefix=parent-dir1/parent-dir2/

enter image description here

like image 70
ericOnline Avatar answered Nov 02 '25 23:11

ericOnline



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!