Get resized images from Google cloud storage

2019-06-17 01:13发布

问题:

When initially loading my website, I need to load a couple of images from my Google cloud storage that have been uploaded by users. To speed up my load time, I would like to get the images in lower resolution.

Is there a way to specify this with the URL, like an additional URL parameter?...

I'm using signed URLs that look like this:

baseURL + "?GoogleAccessId=" + GoogleAccessStorageId + "&Expires=" + Expiration + "&Signature=" + UrlEncodedSignature

as specified here: https://cloud.google.com/storage/docs/access-control#Signed-URLs

回答1:

Not directly, no. AppEngine has an Images API that can serve images from GCS, and that image serving can include transformations, but GCS itself is agnostic to the type of objects it is storing and has no special knowledge of image files or transforming them.

One option would be storing a smaller version of each image at the time that you upload the original. Then you may simply refer to that object directly. A second option would be to serve the images through AppEngine in order to take advantage of its Images API.