Search
 
SCRIPT & CODE EXAMPLE
 

PHP

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 :: file upload permission in php 
Php :: how to log object laravel logger 
Php :: openssl encrypt php with key 
Php :: error_log wordpress 
Php :: grouping route in laravel 
Php :: laravel controller create command in a folder 
Php :: password_verify() php 
Php :: user location using php 
Php :: Error: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress. 
Php :: json encode decode 
Php :: array key value php 
Php :: php remove first word from string 
Php :: how to get display name in wordpress 
Php :: php loop array 
Php :: laravel route contains particular segment 
Php :: php new line 
Php :: how to link image in laravel 
Php :: url() inside laravel config files 
Php :: delete button laravel 
Php :: accessing json data in php 
Php :: define return type for php function string or boolean 
Php :: how to download image from url from a particular div in php 
Php :: calling fucnction in an other function php 
Php :: mail sending setting magneto for mailhog 
Php :: php check if all values in array are equal 
Php :: laravel maximum execution time of 30 seconds exceeded 
Php :: copy folder contect to anthor folder php 
Php :: custom autoload without composer php psr4 
Php :: laravel hash password check 
Php :: login selected user laravel 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =