简体   繁体   中英

Laravel 4 Response::download() from external url source

I can't seem to find out whether it is possible to create a download link via Response::download() method with an external URL file source instead of local file path. For example:

Response::download('https://s3.amazonaws.com/bucket/file.zip','Download.zip');

I'm hosting my static and upload file on Amazon S3 and would like to create a download link when the requested users have access to it. All I get from the testing above is a FileNotFoundException error popping up stating that file does not exist.

As @James Binford said in the comments, it is not possible to use Response::download() for files on an external source. It may not be perfect, but you can always redirect to the URL

Redirect::away('https://s3.amazonaws.com/bucket/file.zip');

Depending on the file type it will open as "normal" download (eg zip files) or, if the browser supports it, the contents of the file will be displayed (eg images or text files)

Alternatively you can download the file from the server to the application server (eg using curl ) and then use Response::download()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM