mercredi 27 septembre 2017

Force download from amazon s3 private file in laravel

Hello i have some problem with doing a force download. Here is my code :

public function download(Request $request, $id) {
  $document = Document::find($id);
  $s3 = Storage::disk('s3');
  $name = substr($document->link, strrpos($document->link, '/') + 1);
  $file = $s3->get($name);
  $headers = [
    'Content-Type' => 'application/pdf',
    'Content-Description' => 'File Transfer',
    'Content-Disposition' => "attachment; filename={$name}",
    'filename'=> $name
  ];
  return response()->download($file);
}

i don't get it how to access the good file

response :

is_file() expects parameter 1 to be a valid path, string given

Any ideas ?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2wXnjz2
via IFTTT

Aucun commentaire:

Enregistrer un commentaire