Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

s3 download files as zip laravel

<?php   
    use IlluminateSupportFacadesStorage;
    use LeagueFlysystemFilesystem;
    use LeagueFlysystemipArchiveipArchiveAdapter;

    Route::get('zip', function(){

        // see laravel's config/filesystem.php for the source disk
        $source_disk = 's3';
        $source_path = '';

        $file_names = Storage::disk($source_disk)->files($source_path);

        $zip = new Filesystem(new ZipArchiveAdapter(public_path('archive.zip')));

        foreach($file_names as $file_name){
            $file_content = Storage::disk($source_disk)->get($file_name);
            $zip->put($file_name, $file_content);
        }

        $zip->getAdapter()->getArchive()->close();

        return redirect('archive.zip');

    });
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #download #files #zip #laravel
ADD COMMENT
Topic
Name
1+2 =