I'm looping through my image files and calling $s3Client->putObject($object);
for each one, but with hundreds of thousands of files, I can see this is going to take forever.
I can't seem to find any batch upload examples for the PHP SDK. Does the PHP SDK provide some kind of batch upload method that will process them more efficiently?
Short answer is - No, there is no batch upload to AWS S3 bucket but for better performance you can use concurrency while you are uploading your stuff to the bucket.
I've made a really simple POC for your issue using concurrency for uploading data to the bucket. First of all because of missing information I've made my poc with latest version of AWS PHP SDK available at this time - 3.171.2 also you will need to install Guzzle if you don't have it. I'm using Guzzle 7.2 but I think this code will work on Guzzle 6+ too.
For my poc I'm using putObjectAsync but you can even try to handle it with Multipart Uploads
My setup:
- php: 7.4.13
- guzzle: 7.2.0
- aws-sdk-php: 3.171.2
Expected output will be something like this:
Hope this will help you to solve your issue.