aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.41k stars 2.11k forks source link

Cannot get full path to a user's S3 Storage file #12766

Closed cadenyoung-st closed 6 days ago

cadenyoung-st commented 8 months ago

Is this related to a new or existing framework?

Next.js

Is this related to a new or existing API?

Authentication, Storage

Is this related to another service?

No response

Describe the feature you'd like to request

I currently have an application where I need to process all user file submissions to S3 in a lambda to create a summary of the file contents. The user submits a Connected Form with a Storage Manager component, and the S3 Storage ID of the file is stored alongside the other form fields. However, there is no way to get this file later in a lambda. This is because, from what I can see, the Storage feature of Amplify uses the Identity ID of the user to create directories for private and protected files. This makes it seem near impossible to actually retrieve the file later (either from a lambda for external processing or even on the frontend).

Describe the solution you'd like

One solution might be to have an option to return the full path to the file, including the region:identity_id/filename when they make a submission to storage. This would allow me to store this in my database for retrieval later. I think there was a function in auth/server that allows me to fetch the Identity ID myself so I can store this alongside the submission so it can be found later, however I'm not sure if either of these solutions would be secure?

Describe alternatives you've considered

I've looked into issues on here that mention switching the S3 Storage to utilize the User Pool ID/sub of the user for the private storage directories. However, from what I read in that issue (which was 1-2 years old), the functionality is no longer possible in newer versions of Amplify. Additionally, I've considered trying to see if it's possible to go directly through the Cognito SDK, however this doesn't seem feasible as the only option would be to get a list of all users, find the user in that list, and get their Identity ID from that somehow every single time I process a submission.

Additional context

I'm open to any solutions that others may have, and I'd love to learn how/if anyone else has successfully managed to do something similar to this.

Is this something that you'd be interested in working on?

cwomack commented 8 months ago

Hello, @cadenyoung-st and thanks for opening this issue. We'll mark this as a feature request, review it internally, and follow up with further questions if additional context is needed.

ashika112 commented 6 days ago

@cadenyoung-st , The feature asked here should be available in Amplify v6 as of version 6.2.0. Please refer to our Storage documentation for usage details.

Let us know if you have any further concerns or issues.