TAGS :Viewed: 7 - Published at: a few seconds ago

[ Laravel: Uploading multiple files on s3 through flysystem ]

I have a system where users can upload zipped files, this zip file is then uploaded to the local drive and extracted. I am aware that uploading a single file is pretty simple.

$s3 = Storage::disk('s3');
$s3->put('myfile.txt', 'This is some dummy data in the file.', 'public');

But the extracted folder will contain roughly around 1000 files. So is there anyway i can upload multiple files to s3 at once?

What i am looking for is a way to upload the whole extracted folder to s3.

Any help is appreciated :)

Answer 1


You can extract foder to local storage.

Use Storage to take all files from extracted archive:

$files = Storage::allFiles($directory);

Afterthis upload to S3, like this

  foreach($files as $file){
     $s3->put($file);
}

Sorry for code i wite to hand :)