Hi,
Struggling a little bit with downloading files from amazon s3 using laravel Storage.
Uploading a file is no problem:
Storage::disk('s3')->put($destination , file_get_contents($request->file), 'public');
But then when I want to download a file i am having difficulty.
$import = CsvImport::find($id);
$file = Storage::disk('s3')->get('uploads/csv/' . $import->filename );
return Response::download($file , $import->filename);
It is definitely returning the contents to the $file variable as I can log it, but how to make it downloadable?
I am thinking I need to add some kind of headers to the file like this:
$headers = [
'Content-Type' => 'text/csv',
'Content-Disposition' => 'attachment',
'filename'=> $import->filename
];
return response()->download($file, $import->filename, $headers);
But I cannot get a download.
Has anyone any experience working with downloading file contents from s3?
Help most appreciated. Thanks