[英]How to get images from Google Cloud Storage and show them in <img> tag using Laravel/PHP
In one of my Laravel based Application, I want to show user images that are stored Google Cloud Storage . 在一个基于Laravel的应用程序中,我想显示存储在Google Cloud Storage中的用户图像。 After some processing, I got the image URL as
gs://< my_custom_domain >/customer/images/< custom_id >/0f393ee5ab484771338268d58d08f5c1.jpg
经过一些处理后,我得到的图片网址为
gs://< my_custom_domain >/customer/images/< custom_id >/0f393ee5ab484771338268d58d08f5c1.jpg
This is not a URL that can access directly!! 这不是可以直接访问的URL!
But I don't find a way to use that URL to get the image from Google Cloud Storage and also have no idea about how to show that image in 但是我找不到使用该URL从Google Cloud Storage获取图像的方法,而且也不清楚如何在 tag.
标签。
Can anyone help me? 谁能帮我?
I think that Cloud Storage Tools API can be useful for you, due to provides some methods that you can use to serve images files. 我认为,由于提供了一些可用于提供图像文件的方法,因此Cloud Storage Tools API对您有用。 Based in the documentation about Serving Images , I think you can use:
基于有关Serving Images的文档,我认为您可以使用:
$options = ['size' => 400, 'crop' => true];
$image_file = "gs://${my_bucket}/image.jpg";
$image_url = CloudStorageTools::getImageServingUrl($image_file, $options);
You can also check this GitHub link to see more code examples about Cloud Storage using PHP. 您还可以检查此GitHub链接,以查看有关使用PHP的云存储的更多代码示例。 Hope this was useful for you!
希望这对您有用!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.