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

Issues with listing subdirectories #44

Closed sithtoast closed 1 year ago

sithtoast commented 1 year ago

I'm hosting a static site on S3. The root of the bucket has an index.html file, but there are a few subdirectories where a listing is needed. I've tried a smattering of things but none seem to work. I get the error

Bucket URL http://dk.toastednet.org.s3-website-us-east-1.amazonaws.com/CM400A/ is not a valid bucket API URL, response does not contain <ListBucketResult><Delimiter> tag.

Can you take a look at it for me and tell me what's wrong? I have several other directories I would like to list so I can apply what I learn here to those :)

 `bucketUrl: undefined,
  // If bucketUrl is undefined, this script tries to determine bucket Rest API URL from this file location itself.
  //   This will only work for locations like these
  //   * https://s3.BUCKET-REGION.amazonaws.com/BUCKET-NAME/index.html
  //   * http://BUCKET-NAME.s3-website-BUCKET-REGION.amazonaws.com/index.html
  //   * https://storage.googleapis.com/BUCKET-NAME/index.html
  //   * https://BUCKET-NAME.s3-web.BUCKET-REGION.cloud-object-storage.appdomain.cloud/
  // If bucketUrl is set manually, ensure this is the bucket Rest API URL, e.g.
  //   * https://s3.BUCKET-REGION.amazonaws.com/BUCKET-NAME
  //   * https://storage.googleapis.com/BUCKET-NAME
  //   The URL should return an XML document with <ListBucketResult> as root element.
  rootPrefix: 'CM400A/', // e.g. 'subfolder/'
  keyExcludePatterns: [/^index\.html$/],
  pageSize: 50,

  bucketMaskUrl: undefined,
  // If bucketMaskUrl is set file urls will be changed from ${bucketUrl}/${file} to ${bucketMaskUrl}/${file}
  //   bucketMaskUrl: 'https://example.org'
  //     => https://example.org/foo/bar.txt
  //   bucketMaskUrl: document.location.origin
  //     => ${document.location.origin}/foo/bar.txt

  defaultOrder: 'name-asc' // (name|size|dateModified)-(asc|desc)
}`

Thank you!

qoomon commented 1 year ago

should be fixed. bucket names with dot were not handled correctly. feel free to try version 1.11.2

sithtoast commented 1 year ago

I'm not seeing any difference. :( Am I missing something or configuring it wrong? I have ACLs set and the bucket policy set.

qoomon commented 1 year ago

@sithtoast it is another problem now.

Access to fetch at 'http://s3.us-east-1.amazonaws.com/dk.toastednet.org?list-type=2&delimiter=/&prefix=dk.toastednet.org/&max-keys=50' 
from origin 'http://dk.toastednet.org.s3-website-us-east-1.amazonaws.com' 
has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

You need to setup your CORS policy. Have a look at CORS Configuration in README.md

qoomon commented 1 year ago
qoomon commented 1 year ago

Hope that helps

qoomon commented 1 year ago

seem to work now http://dk.toastednet.org.s3-website-us-east-1.amazonaws.com/CM400A/

sithtoast commented 1 year ago

Sorry for responding again. I was wondering if there was a way to just list the subdirectory that the index file is placed in. Right now it's listing the root and everything in it.

sithtoast commented 1 year ago

I figured it out. Thanks!

qoomon commented 1 year ago

Sorry for responding again. I was wondering if there was a way to just list the subdirectory that the index file is placed in. Right now it's listing the root and everything in it.

@sithtoast try version 1.11.3