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.

Logged in users can upload but not list files

See original GitHub issue

Describe the bug

I have a react app that is able to upload files to S3, however when trying to list files, the pre-flight OPTIONS request succeeds, but the actual list gets a 403.

The IAM role for the cognito user is:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "mobileanalytics:PutEvents",
                "cognito-sync:*",
                "cognito-identity:*"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "s3:*"
            ],
            "Resource": [
                "arn:aws:s3:::dev-drop-bucket-files/private/${cognito-identity.amazonaws.com:sub}/*",
                "arn:aws:s3:::dev-drop-bucket-files/private/${cognito-identity.amazonaws.com:sub}"
            ],
            "Effect": "Allow"
        }
    ]
}

Here’s a sample of the code that is what I’m using for the uploads/downloads:

import { Storage } from "aws-amplify";

export async function s3Upload(file) {
  Storage.configure({ level: 'private' });
  const stored = await Storage.vault.put(file.name, file, {
    contentType: file.type
  });

  return stored.key;
}
export async function listFiles() {
  Storage.configure({ level: 'private' });
  const files = await Storage.list('/');
  return files;
}

Expected behavior

List should return a list of files.

Desktop (please complete the following information):

  • OS: MacOS
  • Browser Chrome
  • Version 71.0.3578.98

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
manueliglesiascommented, Jan 31, 2019

@marksteele can you try:

Storage.list('', {level: 'private'})
0reactions
github-actions[bot]commented, Jun 12, 2021

This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set folder permissions to only show the logged in user what ...
Hello, Is it possible to set a document library's folder permissions to show the logged in user only what they have created, instead...
Read more >
Customer Portal (Experience) User Can Upload Files to Case ...
However, the Customer Portal (Experience) user is only able to upload files to the case, but not able to see the files uploaded...
Read more >
files and folders must be accessible by logged in users .How ...
You are creating folders, but if someone knows the URL it can access to it. What you could do is allow access only...
Read more >
Manage external sharing for your organization - Google Support
To allow users to open files from domains that aren't on an allowlist and edit Google Docs, Sheets, Slides, and Sites stored on...
Read more >
Tracking User Activity on Files - Box Support
Anonymous users -- people who are not logged in to Box and access a file using a shared link -- are not displayed...
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