Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



Serving Images

The Cloud Storage Tools API provides convenience methods that you can use to serve image files conveniently:

  • CloudStorageTools.getImageServingUrl()
  • CloudStorageTools.deleteImageServingUrl()

One advantage of using this method to serve images rather than simply making the files public using CloudStorageTools::getPublicUrl , is that the image method listed above allows dynamic manipulation, such as image resizing, which means you don't have to store different image sizes.

You use getImageServingUrl returns a URL that serves an image. If the image will be displayed within an HTTPS page, set secure_url to True to avoid mixed-content warnings.

Notice that this URL is publically readable by everyone, but it is not "guessable".

To stop serving the URL, call deleteImageServingUrl .

The following snippet shows how to use this feature, with the image myfile.png made available in a resized and cropped format:

require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageTools;

$object_image_file = 'gs://my-bucket/myfile.png'
$object_image_url = CloudStorageTools::getImageServingUrl($object_image_file,
                                            ['crop' => true]
                                            ['size' => 400]);

header('Location:' .$object_image_url);

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.