question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Storage.list Returning Empty Array

See original GitHub issue

Describe 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:closed
  • Created 4 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
josephpaulmckenziecommented, Jun 12, 2019

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 me

3reactions
vincent38wargniercommented, Dec 24, 2021

Hi, 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. image

That’s why all the other files contained in the bucket outside of the “public” folder are not returned.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found