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

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

PREVIOUS NEXT
Code Example
Php :: php delete directory 
Php :: php echo new line terminal 
Php :: rand string php 
Php :: add time to a date php 
Php :: php time to date 
Php :: running laravel queues in shared hosting 
Php :: check null in_array php 
Php :: php query pdo 
Php :: laravel eloquent soft delete 
Php :: how to change php version in cpanel 
Php :: Remove the Breadcrumbs on the Shop Entirely 
Php :: php get day of week 
Php :: php rand vs mt_rand 
Php :: php intval 
Php :: encrypt & decrypt laravel 
Php :: laravel validation image or file 
Php :: php convert 
Php :: how to alias table name in laravel model 
Php :: why does php syntax doesnt work in my html 
Php :: php count 
Php :: join array of strings php 
Php :: symfony set timezone 
Php :: php match 
Php :: php example 
Php :: Laravel Framework upgrade from older version 7.x to 8.x 
Php :: php sha512 hash 
Php :: wordpress get plugin root directory 
Php :: laravel eloquent set timestamps values upon seed 
Php :: pluck laravel 
Php :: laravel model fillable vs guarded 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =