$s3_file = Storage::disk('s3')->get(request()->file);
$s3 = Storage::disk('public');
$s3->put("./file_name.tif", $s3_file);
$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);
return Storage::download('file.jpg');
return Storage::download('file.jpg', $name, $headers);
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);
}
$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);
composer require league/flysystem-ziparchive
composer require league/flysystem-ziparchive
<?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');
});