Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make batch copy requests to AWS S3 with Python

I wrote a lambda function to copy files in an s3 bucket into another s3 bucket and I need to move a very large number of these files. To try and meet the volume requirements I was looking for a way to send these requests in large batches to S3 to cut down on overhead. However I cannot find any information on how to do this in Python. There's a Batch class in the boto3 documentation but I can't make sense of how it works or even what it actually does.

like image 277
avorum Avatar asked Apr 20 '26 10:04

avorum


1 Answers

There is no underlying Amazon S3 API call that can copy multiple files in one request.

The best option is to issue requests in parallel so that they will execute faster.

The boto3 Transfer Manager might be able to assist with this effort.

Side-note: There is no such thing as 'move' command for S3. Instead, you will need to copy, then delete. Just mentioning it for other readers.

like image 67
John Rotenstein Avatar answered Apr 22 '26 10:04

John Rotenstein



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!