Amplify-js: Storage.list Returning Empty Array

Created on 22 Apr 2019  路  5Comments  路  Source: aws-amplify/amplify-js

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

React Storage pending-close-response-required

Most helpful comment

After turning on logs, found the following:

if path provided
[DEBUG] 58:15.430 AWSS3Provider - list <path>/ from public/<path>

if path not provided
[DEBUG] 01:21.831 AWSS3Provider - list from public/

Then after manually adding public/ folder within bucket, things started working and able to see list of items and folders.

All 5 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 me

@josephpaulmckenzie tried that and still not able to get it working.

After turning on logs, found the following:

if path provided
[DEBUG] 58:15.430 AWSS3Provider - list <path>/ from public/<path>

if path not provided
[DEBUG] 01:21.831 AWSS3Provider - list from public/

Then after manually adding public/ folder within bucket, things started working and able to see list of items and folders.

@tmoore23, is this issue safe to close?

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

karlmosenbacher picture karlmosenbacher  路  3Comments

cgarvis picture cgarvis  路  3Comments

cosmosof picture cosmosof  路  3Comments

romainquellec picture romainquellec  路  3Comments

epicfaace picture epicfaace  路  3Comments