Storage.list Returning Empty Array
See original GitHub issueDescribe the bug I have created a react native app but I am running into an issue where I am not able to list my directories and content of the directories in the my S3 bucket. I am using the following code:
componentWillMount(){
console.log('Calling S3');
console.log(Auth.currentCredentials());
Storage.list('/', { level: "public" })
.then (result => console.log('Result:', result)) // {key: "test.txt"}
.catch(err => console.log(err)});
}
Expected behavior To see directories and contents of directories in S3 bucket.
Related issue: #2828
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Storage.list() returning an empty array - Stack Overflow
With the debug logs, I can see that it is properly resolving the path, as I am getting the correct path shown, but...
Read more >Storage Directories Returns Empty Array - Laracasts
Ok, I'm stumped I'm trying to list all of the folders within a given directory and all I'm getting is an empty array?...
Read more >ListObjects - Amazon Simple Storage Service
Returns some or all (up to 1,000) of the objects in a bucket. You can use the request parameters as selection criteria to...
Read more >Empty arrays and collections should be returned instead of null
Returning null instead of an actual array, collection or map forces callers of the method to explicitly test for nullity, making them more...
Read more >Array | Apple Developer Documentation
You can create an empty array by specifying the Element type of your array ... Suppose you need to store a list of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just now figured this out as I was having the same issue. Take out the forward slash in Storage.list() and make it like
Storage.list('', { level: "public" }) .then (result => console.log('Result:', result)) // {key: "test.txt"} .catch(err => console.log(err)});
When you have it like ‘/’ it adds another / at the end of the url and breaks it. Seems like a bug to meHi, I had a similar issue, and the solution for me is not mentioned here. My problem was that I was trying to retrieve data readable by guests, so in public accès. To get public data, you will need to create a “public/” folder inside your bucket, and Storage.list(‘’) will return all the elements contained in this folder only.
That’s why all the other files contained in the bucket outside of the “public” folder are not returned.