Search
 
SCRIPT & CODE EXAMPLE
 

PHP

download data from s3 and save to local disk laravel

 $s3_file = Storage::disk('s3')->get(request()->file);
 $s3 = Storage::disk('public');
 $s3->put("./file_name.tif", $s3_file);
Comment

laravel download file from s3

$attachment = TicketAttachment::find($id);
$headers = [
    'Content-Type'        => 'application/jpeg',
    'Content-Disposition' => 'attachment; filename="'. $attachment->name .'"',
];
return Response::make(Storage::disk('s3')->get($attachment->url), 200, $headers);
Comment

laravel s3 download file

return Storage::download('file.jpg');

return Storage::download('file.jpg', $name, $headers);
Comment

download file laravel s3

public function downloadAsset($id)
    {
        $asset = Asset::find($id);
        $assetPath = Storage::disk('s3')->url($asset->filename);

        header("Cache-Control: public");
        header("Content-Description: File Transfer");
        header("Content-Disposition: attachment; filename=" . basename($assetPath));
        header("Content-Type: " . $asset->mime);

        return readfile($assetPath);
    }
Comment

download file laravel s3

$event_data = $this->ticket->where('user_id', $user_id)->first();
        
$data  = $event_data->pdf;

$get_ticket = 'tickets/'. $data;
$file_name  = "YOUR_DESIRED_NAME.pdf";

$headers = [
  'Content-Type'        => 'application/pdf',            
  'Content-Disposition' => 'attachment; filename="'. $file_name .'"',
];

return Response::make(Storage::disk('s3')->get($get_ticket), 200, $headers);
Comment

s3 download files as zip laravel

composer require league/flysystem-ziparchive
Comment

s3 download files as zip laravel

composer require league/flysystem-ziparchive
Comment

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');

    });
Comment

PREVIOUS NEXT
Code Example
Php :: php call method from another class 
Php :: laravel uuid not showing in query 
Php :: codeigniter sanitize input field 
Php :: display data from two dimensional array in vew laravel 
Php :: Program for factorial of a number in php 
Php :: how to setup cron job for laravel queues on shared hosting 
Php :: join string php 
Php :: php webserver 
Php :: append in php 
Php :: PHP strrpos — Find the position of the last occurrence of a substring in a string 
Php :: database, counts,php, 
Php :: php explode empty string 
Php :: wordpress get wp roles 
Php :: firstOrFail() 
Php :: php foreach skip to next 
Php :: laravel collection when 
Php :: laravel 8 resource 
Php :: php api connection 
Php :: how to print something in php 
Php :: unique check two clolumn in laravel validation 
Php :: Simple 301 redirect 
Php :: codeigniter select where 
Php :: Try raising max_execution_time setting in php.ini file (CentOS path is /etc/php.ini): max_execution_time = 300Fix 504 Gateway Timeout using Nginx 
Php :: laravel migration text length 
Php :: php glob sort by unsigned int 
Php :: silverstripe image upload field 
Php :: php sentense case 
Php :: PHP is not configured to connect to MySQL 
Php :: like query with prepare wordpress 
Php :: to list all relations of model laravel 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =