Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3 #10938

Closed
build-for-life opened this issue Feb 5, 2023 · 4 comments
Closed

S3 #10938

build-for-life opened this issue Feb 5, 2023 · 4 comments
Assignees
Labels
feature-request Request a new feature Storage Related to Storage components/category transferred This issue was transferred from another Amplify project

Comments

@build-for-life
Copy link

build-for-life commented Feb 5, 2023

No description provided.

@build-for-life build-for-life added the question General question label Feb 5, 2023
@nadetastic nadetastic transferred this issue from aws-amplify/amplify-hosting Feb 7, 2023
@nadetastic nadetastic self-assigned this Feb 7, 2023
@nadetastic nadetastic added Storage Related to Storage components/category transferred This issue was transferred from another Amplify project pending-triage Issue is pending triage labels Feb 7, 2023
@hdworld11
Copy link
Member

Hello @atef-abdellatif, thank you for opening this issue! This is very relevant to the APIs and Developer Experience for Storage. We are taking this into consideration for our roadmap and will update this issue on any progress.

@nadetastic
Copy link
Member

@atef-abdellatif Adding to the above, since Amplify Storage currently supports putting one object at a time with Storage.put, a work around could be to loop through the call based on the number of objects. Here's an example of how you could implement this:

Ex:

// Array of files that has the "key" and "content" attributes needed by Storage.put(key,content), reference at [1] below
const files = [
    {key, content,...otherAttributes},
    {key, content,...otherAttributes},
    ...
];

// wrapper for Storage.put that takes in each object from the array
const putWrapper = async (object) => {
    try {
      const res = await Storage.put(object.key,object.text,...additionalAttributes)
    }catch(e){
      console.error(e)
    }
  }

// handler that can be triggered to loop through the "files" array and invoke "putWrapper"
  const handler = async () => {
    for (let index = 0; index < files.length; index++) {
      await putWrapper(files[index])
    }
  }

[1] https://docs.amplify.aws/lib/storage/upload/q/platform/js/#upload-files

@nadetastic nadetastic added feature-request Request a new feature and removed question General question pending-triage Issue is pending triage labels Feb 8, 2023
@nadetastic
Copy link
Member

Hi @atef-abdellatif

Glad that the work around worked for you! Regarding your follow up questions, note that Amplify currently supports using one S3 bucket at a time - so multiple buckets would not work directly.

However in order to store objects in sub folders, you can include a path with your key when running Storage.put. For example, to have a folder named "documents", you would do:

await Storage.put('documents/foo.txt','This is sample text')

This would place the "foo.txt" file in the "public/documents/" folder.

Additionally, I would recommend taking a look at the link at [1] below which discusses various access levels for public, private, and protected.

[1] https://docs.amplify.aws/lib/storage/configureaccess/q/platform/js/

@ashika112
Copy link
Member

@atef-abdellatif The feature to upload images to specific buckets is now enable in Amplify v6(version 6.5.1). More information available here.

Does this close this feature request? I also see there is uploading multiple images to S3, the suggestion provided in this comment would be the best way to achieve that. Unfortunately S3 does not support batch upload.

@build-for-life build-for-life closed this as not planned Won't fix, can't repro, duplicate, stale Dec 31, 2024
@build-for-life build-for-life changed the title Upload MULTIPLE images to S3 Bucket from Amplify app (React) S3 Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request a new feature Storage Related to Storage components/category transferred This issue was transferred from another Amplify project
Projects
None yet
Development

No branches or pull requests

4 participants