I'm currently using the standard Laravel file storage to upload a single file to S3 but now have a need to upload a whole load of separate files at once (possibly up to 200). I want to do this as efficiently as possible, rather than using separate requests. Is this possible somehow, either using Laravel storage, the Flysystem library it's based on or the official Amazon S3 PHP SDK?
Separate files are very small, about 1Kb each.
I struggled with this for a long time. I finally caved in and now use a service - filestack.
Honestly... it costs me $19 a month but I would pay more. They make uploading and asset storage a dream.
PS. I absolutely do not work or am affiliated in anyway with that company. I just struggled for so long with trying to create a nice file upload experience and they have changed my life (and my app) hugely for the better.
@ajck I wrote an Artisan command to upload a directory of files to S3. It involves using MultipartUploader() and Promises. It handled 25 concurrent uploads and several of these were > 1GB. I was very impressed in the end. roughly it went like this...
@AJCK - Hi @ajck What $this->fetchFilenamesToUpload() did was to iterate a directory, and yield the $keyToFile => $pathToFile so I could handle any size and it fitted the promise model. However, yes it's basically a filename => path key pair.
Personally I only ever use env() in config files but shouldn't make any difference. Better to move the env() call outside the loop though and assign a variable imho.
Because it was only a devtool, I did not go too deep into error recovery. I did try it, but it didn't recover very well LOL.