Upload data to S3 using lambda


I am currently working on a mobile app on which we have implemented data storage in S3 bucket. What we are currently doing is that we are generating presigned url from lambda and then sending it to the react native app on front end from where we upload the data.

The difficulty we are facing is that as we can have upto 10-15 files at a given time and it will affect the user experience of the mobile app. So, is there any way we can upload the files to S3 bucket from lambda instead of doing from front end?

2 Answers

This may not be what you're looking for, but I use python and you may be using the same functions on your front end, so this may help you. Not sure.

Here's what I'm doing:

mb = 1024 ** 2

config = TransferConfig(multipart_threshold=1024 * 25, max_concurrency=int(psutil.cpu_count() / 2),
                        multipart_chunksize=1024 * 25, use_threads=False)

    upload_file_response = s3.upload_file(source, destination, key, Config=config)

There's an article that mentions you can limit the bandwidth of the connection you're using in the TransferConfig class options. Here's that article: Again, this may or may not help you. Sorry if it doesn't.


answered a year ago

Not sure what you are concerned about. Is it the fact that you need to generate 10-15 pre-signed URLs? What about it? The time it takes?

You can always generate all the URLs in a single API call. Also, if you are using Cognito user pools to authenticate the users, you can also associate an Identity pool, obtain AWS credentials on the client and generate the pre-signed URLs there, saving on the network round trip.

Finally, you can upload the files to Lambda that will save to S3. Not sure it will be quicker. Note that Lambda has a 6MB payload size limit.

profile pictureAWS
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions