简体   繁体   English

如何从Google Cloud Storage获取图像并将其显示在 <img> 使用Laravel / PHP标记

[英]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.

相关问题 使用 Laravel 从 Google Cloud Storage 获取所有文件夹和图像 - Get all Folders and Images from Google Cloud Storage with Laravel Google App Engine:如何在 PHP 循环中从 Google 云存储提供上传的图像 - Google App Engine: How to serve uploaded images in a PHP loop from google cloud storage 如何使用src属性从另一个驱动器检索和显示图像 <img> 标签? - How to retrieve and show images from another drive using src attribute in <img> tag? 如何从 PHP 表单将图像上传到 Google Cloud Storage? - How do I upload images to the Google Cloud Storage from PHP form? Google Cloud Storage获取临时文件名(使用fopen(&#39;php:// temp&#39;)) - Google Cloud Storage get temp filename (using fopen('php://temp')) 如何从远程PHP应用程序使用Google云存储get_serving_url - How to use google cloud storage get_serving_url from remote php app 如何解析并获取网址 <img> 使用smarty和php从HTML标记? - How to parse & get url of the <img> tag from HTML using smarty and php? GAE PHP提供云存储中的图像 - Gae php serve images from cloud storage 如何使用PHP将图像上传到谷歌云存储与GAE - how to upload a image to google cloud storage with GAE using php 如何使用php将文件上传到Google云存储中存储桶中的子文件夹 - how to upload file to subfolder in bucket in google cloud storage using php
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM