Laravel: Uploading multiple files on s3 through flysystem

2.1k Views Asked by At

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 :)

1

There are 1 best solutions below

0
On

You can extract folder to local storage.

Use storage to take all files from extracted archive:

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

After this upload to S3, like this:

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

Sorry for code i write to hand :)