Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用Response::download()从AWS S3下载文件_Php_Amazon Web Services_Laravel - Fatal编程技术网

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

Php 使用Response::download()从AWS S3下载文件,php,amazon-web-services,laravel,Php,Amazon Web Services,Laravel,给我: 未处理的异常 信息: filesize[function.filesize]:stat在解决方案:/laravel/response.php中失败 您不能在aws文件上使用File::size,因为File::size===filesize,并且无论出于何种原因,该函数都无法绘制S3文件的图形 public function get_download($record_id) { $record = Record::find($record_id); $file_name

给我:

未处理的异常

信息:


filesize[function.filesize]:stat在解决方案:/laravel/response.php中失败

您不能在aws文件上使用File::size,因为File::size===filesize,并且无论出于何种原因,该函数都无法绘制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;
    */
}