我们如何使用 firebase 图像文件并使用 get_Serving_URL 调整它们的大小 [英] how can we use firebase image file and resize them using get_Serving_URL

查看:16
本文介绍了我们如何使用 firebase 图像文件并使用 get_Serving_URL 调整它们的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用谷歌云服务并发现以下只能使用 blob 实现,但我想使用云存储中的图像名称.

I just started using google cloud services and found that the following can be only implemented using blob but i want to use image name from cloud storage.

如果有的话,有没有办法使用servingURL来调整图像的大小我如何实现它,即我如何从云存储中提供存储桶名称和图像名称?

Is there a way to resize the images using servingURL if so how can i implement it i.e. how can i give the bucket name and image name from cloud storage ?

并构造URL并传递参数

and construct the URL and pass the parameters

有什么博客或代码可以参考吗?

is there any blog or code that i can refer ?

推荐答案

这里是调整图片大小的博客

here is the blog to resize the image

这是示例 PHP 代码,但如何使其在 FireBase 中工作,您需要参考以下链接点击此处阅读更多内容

This is the sample PHP code but how to make it working in FireBase you need to refer the link below click here to read more

index.php:

<?php
//var_dump($_FILES['uploaded_files']['tmp_name']);
syslog(LOG_WARNING, "Request came");
require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use googleappengineapicloud_storageCloudStorageTools;
syslog(LOG_WARNING, "Imported Cloud Storage Tools");
//var_dump( $_GET);
$object_url=$_GET["image"];
$size=intval($_GET["size"]);
syslog(LOG_WARNING, "Object URL $object_url");
syslog(LOG_WARNING, "Size $size");

$bucket="gs://YOUR-PROJECT-ID.appspot.com/bucket_name/";
$object_image_url = CloudStorageTools::getImageServingUrl($object_url,['size' => $size, 'crop' => false]);
syslog(LOG_WARNING, "Output Url $object_image_url");
header("location: $object_image_url");

closelog();
?>



app.yaml:

runtime: php55
api_version: 1

handlers:
- url: /.*
script: index.php

这篇关于我们如何使用 firebase 图像文件并使用 get_Serving_URL 调整它们的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆