Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can we use firebase image file and resize them using get_Serving_URL

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.

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 ?

and construct the URL and pass the parameters

is there any blog or code that i can refer ?

like image 713
Nikhil Kulkarni Avatar asked Dec 06 '25 21:12

Nikhil Kulkarni


2 Answers

The get_serving_url() is part of App Engine and thus you can't use it in Firebase (unless Firebase will eventually supports it), but you can definitely store the images in the Google Cloud Storage instead of Blobstore, which is by the way is the recommended way.

like image 64
Lipis Avatar answered Dec 09 '25 10:12

Lipis


here is the blog to resize the image

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 google\appengine\api\cloud_storage\CloudStorageTools;
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
like image 29
Nikhil Kulkarni Avatar answered Dec 09 '25 11:12

Nikhil Kulkarni