【问题标题】:Using Response::download() to download a file from AWS S3使用 Response::download() 从 AWS S3 下载文件
【发布时间】:2013-01-18 15:57:31
【问题描述】:
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;
    */
}

给我:

未处理的异常

消息:

filesize() [function.filesize]: https://s3.amazonaws.com/webapp/uploads/laravelsasuce.png 的统计失败

【问题讨论】:

    标签: php amazon-web-services laravel


    【解决方案1】:

    解决方案:/laravel/response.php

    您不能在 aws 文件上使用 File::size,因为 File::size() === filesize() 并且该函数无论出于何种原因都无法绘制 S3 文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-23
      • 1970-01-01
      • 2018-10-10
      • 1970-01-01
      • 2021-06-26
      • 1970-01-01
      • 2016-01-02
      • 2018-11-17
      相关资源
      最近更新 更多