【问题标题】:How to get images from Google Cloud Storage and show them in <img> tag using Laravel/PHP如何使用 Laravel/PHP 从 Google Cloud Storage 获取图像并在 <img> 标签中显示它们
【发布时间】:2019-07-25 22:25:43
【问题描述】:

在我的一个基于 Laravel 的应用程序中,我想显示存储在 Google Cloud Storage 的用户图像。经过一些处理,我得到了图片网址为gs://&lt; my_custom_domain &gt;/customer/images/&lt; custom_id &gt;/0f393ee5ab484771338268d58d08f5c1.jpg

这不是可以直接访问的网址!!

但我找不到使用该 URL 从 Google Cloud Storage 获取图像的方法,也不知道如何在 标记中显示该图像.

谁能帮帮我?

【问题讨论】:

    标签: php laravel google-cloud-storage


    【解决方案1】:

    我认为 Cloud Storage Tools API 对您很有用,因为它提供了一些可用于提供图像文件的方法。 根据有关Serving Images 的文档,我认为您可以使用:

    $options = ['size' => 400, 'crop' => true];
    $image_file = "gs://${my_bucket}/image.jpg";
    $image_url = CloudStorageTools::getImageServingUrl($image_file, $options);
    

    您还可以查看GitHub link 以查看更多关于使用 PHP 进行云存储的代码示例。 希望这对您有用!

    【讨论】:

      猜你喜欢
      • 2017-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-13
      • 2015-12-17
      • 1970-01-01
      • 2019-12-02
      • 1970-01-01
      相关资源
      最近更新 更多