Upload data to S3 using lambda

0

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 個答案
1

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)

try:
    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.

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/customizations/s3.html#boto3.s3.transfer.TransferConfig

已回答 2 年前
0

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
專家
Uri
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南