在我的一个基于Laravel的应用程序中,我想显示存储在Google Cloud Storage中的用户图像。经过一番处理,我得到了图像 URL 作为gs://< my_custom_domain >/customer/images/< custom_id >/0f393ee5ab484771338268d58d08f5c1.jpg
这不是可以直接访问的网址!!
但是我没有找到使用该URL从Google云存储获取图像的方法,也不知道如何在标签中显示该图像。
谁能帮我?
我认为云存储工具 API 对您很有用,因为它提供了一些可用于提供图像文件的方法。根据有关提供图像的文档,我认为您可以使用:
$options = ['size' => 400, 'crop' => true];
$image_file = "gs://${my_bucket}/image.jpg";
$image_url = CloudStorageTools::getImageServingUrl($image_file, $options);
您还可以查看此 GitHub 链接,以查看有关使用 PHP 的云存储的更多代码示例。希望这对你有用!