如何获取 AWS S3 图像作为流视图?
现在我可以看到如下网址的图像:
<img src="https://s3.us-east-1.amazonaws.com/my-bucket/image.png" />
我想要这样:
<img src="https://myproject.com/upload/image.png" />
我尝试如下,但没有奏效。我的路线:
Route::get('/upload/{path_to_image}', 'FileController@getImage')->where('path', '(.*)');
-我的控制器
public function getImage($disk, $path)
{
$headers = array(
'Content-Type: application/image',
);
if(Storage::disk("s3")->exists($path))
{
$file = Storage::disk("s3")->path($path);
return response()->file($file, $headers);
}
abort(404);
}
任何建议将不胜感激!