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
You can use Firebase Javascript SDK to send your files to Google Storage, and build an API samples with PHP + library from AppEngine for generating the URL of the object, are same bucket locate.
In app PHP, remember to put following content in app.yaml
:
runtime: php55
api_version: 1
handlers:
- url: /.*
script: index.php
Before, using gcloud
, deploy your sample API:
gcloud app deploy
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.
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