我正在使用 Laravel 5.6。该文档说我可以使用以下代码在用户浏览器中显示文件:
return response()->file($pathToFile);
Run Code Online (Sandbox Code Playgroud)
如何让它与非公开的 S3 文件一起使用?我已经尝试过以下方法:
return response()->file(Storage::disk('private')->path("my_directory/{$fileName}");
Run Code Online (Sandbox Code Playgroud)
但它会抛出“找不到文件”错误。
编辑:这是我的解决方法:
return response(Storage::disk('private')->get("my_directory/{$fileName}"), 200)
->header('Content-Type', 'application/pdf')
->header('Content-Disposition', 'inline');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1106 次 |
| 最近记录: |