0

I have a file stored in an s3 bucket. I can upload fine but when I try to download using the code below I get file not found exception thrown e.g.

Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException
The file "https://s3.us-west-2.amazonaws.com/mybucket/puppy.jpg" does not exist

When I navigate to the same url in a browser, the file downloads fine.

This is my code:

  return response()->download(Storage::disk('s3')->url($file->path), $file->name);

Any ideas what I'm doing wrong?

adam78
  • 9,668
  • 24
  • 96
  • 207

1 Answers1

0

This seems to work unless anyone know a more efficient technique:

 return response()->streamDownload(function () use ($file) {
        echo file_get_contents(Storage::disk('s3')->url($file->path));
    } , $file->name);
adam78
  • 9,668
  • 24
  • 96
  • 207