qoomon / aws-s3-bucket-browser

Single page application to browse AWS S3 bucket content
https://qoomon.github.io/aws-s3-bucket-browser/index.html?bucket=https://s3.amazonaws.com/spacenet-dataset#
MIT License
246 stars 85 forks source link

Great project - update example to new AWS S3 URL structure #56

Closed ventz closed 3 months ago

ventz commented 3 months ago

Hi,

Great project! Thanks for releasing this.

It was not working initially for me until I started browsing the demo and reversing a bit of what was going on.

It turns out 2 things are needed for the new AWS S3 URL structure:

1.) bucketUrl should be set to https://s3.amazonaws.com/BUCKET-NAME (assuming us-east-1)

2.) The cors should be

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "GET"
        ],
        "AllowedOrigins": [
            "https://BUCKET-NAME.s3.amazonaws.com",
            "https://s3.us-east-1.amazonaws.com/BUCKET-NAME",
            "https://s3.amazonaws.com/BUCKET-NAME"
        ],
        "ExposeHeaders": [
            "x-amz-server-side-encryption",
            "x-amz-request-id",
            "x-amz-id-2"
        ],
        "MaxAgeSeconds": 3000
    }
]

It would be helpful if you could update your example:

...
// If bucketUrl is set manually, ensure this is the bucket Rest API URL, e.g.
      //   * https://s3.BUCKET-REGION.amazonaws.com/BUCKET-NAME

To show:

// If bucketUrl is set manually, ensure this is the bucket Rest API URL, e.g.
      //   * https://s3.amazonaws.com/BUCKET-NAME

As it seems for us-east-1 for some reason providing the region is not enough.

Leaving this as it hopefully helps someone else that's stuck.