【发布时间】:2022-01-13 01:58:28
【问题描述】:
我目前正在为需要从 S3 获取特定文件、读取其内容并以二进制文件返回的项目制定路线。我不能只使用 S3 文件 url,因为它是私有的并且是有意的(我们只是不希望存储桶文件打开)。
但问题是,我想在新页面中流式传输它而不需要下载文件。
服务:
$file = $this->s3Provider->getFileContents(false); // gets the file binary
return $file;
控制器:
return response()->streamDownload(function() use($file) {
echo $file; // streams data to download it, but I want just to show the file...
}, $filename);
【问题讨论】:
标签: php laravel amazon-s3 laravel-8