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

Reduce size of image uploads to S3 with Storage.put #10930

Open
2 tasks
redacr11 opened this issue Feb 6, 2023 · 7 comments
Open
2 tasks

Reduce size of image uploads to S3 with Storage.put #10930

redacr11 opened this issue Feb 6, 2023 · 7 comments
Labels
Expo For issues where expo is in use feature-request Request a new feature React Native React Native related issue Storage Related to Storage components/category

Comments

@redacr11
Copy link

redacr11 commented Feb 6, 2023

Is this related to a new or existing framework?

React Native

Is this related to a new or existing API?

Storage

Is this related to another service?

No response

Describe the feature you'd like to request

Currently, when uploading images to S3 via Storage.put it uploads the image as it is without reducing the size of it. In the case that the picture is not big it's not a real problem; the real issue arises when the image I'm trying to upload is rather large.

Describe the solution you'd like

I think having some sort of parameters to pass to decide the compression ratio and/or height and width of the photo that will be uploaded on S3 would be fantastic.

Describe alternatives you've considered

I'm currently building an app using React Native with Expo and the only solution available so far is manipulateAsync. It does compress the image but it does not work when used in conjunction with Storage.put.

Additional context

No response

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

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change
@redacr11 redacr11 added the pending-triage Issue is pending triage label Feb 6, 2023
@hdworld11
Copy link
Member

hdworld11 commented Feb 6, 2023

Hello @redacr11, thank you for raising this request! We are actively looking into ways we can improve the Storage APIs and this is definitely something that we are taking into consideration. We will keep this issue updated as we make progress towards this feature.

@nadetastic nadetastic added Storage Related to Storage components/category feature-request Request a new feature and removed pending-triage Issue is pending triage labels Feb 6, 2023
@stocaaro
Copy link
Member

stocaaro commented Feb 7, 2023

Hello @redacr11,

Glad to take this input into the review that @hdworld11 is leading to look at future behavior for Storage. Would you expect the compression to take place on the client before it is uploaded or to be uploaded full size and resized by resources in the cloud?

I think there may be workarounds in either case such as those suggested by stackoverflow users to resize in app or using lambda triggers to resize uploads to s3. I've explored this use-case using lambda triggers, but haven't tried any of the client side resize options.

@redacr11
Copy link
Author

redacr11 commented Feb 8, 2023

I did try to use the ImageManipulator package from Expo but, after uploading the result of that operation to Storage things went wrong. I can see that the image has been uploaded to S3 but when I try to download it to check if it worked I get the error saying that the image couldn't be opened.
I think that the result of ImageManipulator is not compatible with Storage/S3.

I haven't tried the lambda approach as I'm not sure how to use it. I would have thought that having the compression option in the Storage.put operation would have made things a lot easier, but I'm not sure how long that will take to implement?

@nadetastic nadetastic added React Native React Native related issue Expo For issues where expo is in use labels Feb 8, 2023
@redacr11
Copy link
Author

Hello, are there any updates on this?

@stocaaro
Copy link
Member

Hi @redacr11 ,

From your response, it sounds like you would prefer to do the resizing after the file is uploaded to the cloud, either in node or a lambda. I would recommend trying the lambda approach. This is on our list to consider as a future feature request, but isn't being worked on actively at this time.

I found an example of doing this that was posted a few years back. Some of the specifics might be a bit different, you may find a more recent tutorial with a bit of searching.

@redacr11
Copy link
Author

redacr11 commented Mar 1, 2023

Hi @stocaaro,

Apologies for the late reply. I tried having a look at example you linked but for some reason it didn't work. However, I've found another tutorial/blog post here that was working fine for me.

I think this can do until we get something inside Amplify 🙂

@jtweeks
Copy link

jtweeks commented Apr 12, 2023

lambda trigger when file is uploaded, then nodejs function to reduce size, or create thumb etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Expo For issues where expo is in use feature-request Request a new feature React Native React Native related issue Storage Related to Storage components/category
Projects
None yet
Development

No branches or pull requests

5 participants