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.

S3 private files for multiple users

See original GitHub issue

Hi,

I do manage to store private files but only the owner can get these files (with Storage.vault(key)) with AWS Cognito authentication and verification (JWT).

How to get these files for multiple authorized users like for a chat application ?

I want that only members can get images :

type Conversation

  @model(subscriptions: { level: public })
  @auth(
    rules: [
      { allow: owner, ownerField: "members" }
      { allow: groups, groups: ["admin"], operations: [read] }
    ]
  ) {
  id: ID!
  **members: [String!]!**
  user: User @connection(name: "UserConversations")
  messages: [Message] @connection(name: "ConversationMessages")
  createdAt: String
  updatedAt: String
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
rudyhadouxcommented, Feb 27, 2021

Hi, I finally use pre-signed URLs (with TTL). I put the URL in a private member of an Amplify object.

1reaction
akshbhucommented, Mar 15, 2020

Hi @rudyhadoux

I think to access S3 private files in your chat application, you can give access to them via Presigned urls.

These are the steps that you can follow

  1. Store the image in S3
  2. Do a mutation to create the User in the GraphQL API using the image id
  3. Query the image data from the API using image id
  4. Get a signed URL for the image from S3.

With this url members user will be able to access private images in S3.

Let me know if this works or related to your question.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Controlling access to a bucket with user policies
This walkthrough explains how user permissions work with Amazon S3. In this example, you create a bucket with folders. You then create AWS...
Read more >
Allow multiple users access to private S3 folder using IAM roles
I want to do the following: ... Everything I've found online revolves around each user having their own folder by creating an IAM...
Read more >
Share Your AWS S3 Private Content With Others, Without ...
Amazon Web Services (AWS) S3 objects are private by default. Only the object owner has permission to access these objects.
Read more >
Managing Private Files With AWS S3 | by Hernan Reyes
This solution is what I used when I migrated images. It basically consists in creating a backend endpoint that will validate if the...
Read more >
Secure the files in your Amazon S3 bucket - AWS re:Post
By default, all S3 buckets are private and can be accessed only by users who are explicitly granted access. Restrict access to your...
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