Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List of files #3

Open
marcosberghahn opened this issue Jul 13, 2017 · 3 comments
Open

List of files #3

marcosberghahn opened this issue Jul 13, 2017 · 3 comments

Comments

@marcosberghahn
Copy link

Awesome script man!
Can you add a way to get a list of files inside a bucket?
Or can you point me in the right direction to it?

Thanks in advance. Best!

@bobdevries
Copy link

bobdevries commented Nov 1, 2019

Hey Marcos,

You could do something like this:

const bucketName = "<name of your bucket>"
var responseBlob = s3.getObject(bucketName,"?list-type=2",{logRequests:false})

To narrow down your result you could provide parameters like prefix, delimiter and maxkeys. Be sure to write everything lower case as only this works in my experience.
(i.e. "?list-type=2&prefix=prefix&maxkeys=10").
Further documentation can be found here:

Hope this helps!

@NobleUplift
Copy link

This is exactly what I ended up doing, just using getObject to list objects, since ListObjects only needs GET parameters.

WARNING! Do not use capital letter like it says to in the AWS REST documentation, like ?Prefix=folder&Delimiter=/, because it will cause a signature mismatch and AWS will reject your request.

I believe this is due to line 351, but even when I removed toLowerCase(), the command went through but AWS ignored the parameters (listed every file in the bucket).

@woutergelling
Copy link

var responseBlob = s3.getObject(bucketName,"?list-type=2",{logRequests:false})

This exact request is not working for me, returns a signature does not match error. Any ideas what could cause this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants