dorpbn1027 2013-02-03 23:13
浏览 404

使用Response :: download()从AWS S3下载文件

public function get_download($record_id)
{
    $record = Record::find($record_id);
    $file_name = $record->with_value('File Upload')->name;

    // something like https://s3.amazonaws.com/webapp/uploads/laravelsauce.png
    $file_url = read_file($record->with_value('File Upload')->value);

    return Response::download($file_url, $file_name);

    /*
    // works but why not the above
    header('Content-Type: application/octet-stream');
    header("Content-Transfer-Encoding: Binary");
    header("Content-disposition: attachment; filename='{$file_name}'");
    readfile($file_url);
    exit;
    */
}

Gives me:

Unhandled Exception

Message:

filesize() [function.filesize]: stat failed for https://s3.amazonaws.com/webapp/uploads/laravelsasuce.png

  • 写回答

1条回答 默认 最新

  • dongleman4760 2013-02-03 23:13
    关注

    Solution: /laravel/response.php

    You can't use File::size on an aws file because File::size() === filesize() and that function can't graph the S3 file for whatever reason.

    enter image description here

    评论

报告相同问题?