I\'m trying to rotate / flip an image that is already sitting inside Google Cloud Storage.
This is the blobkey:
BlobKey blobKey = new BlobKey(upload.
To override the original image, you simply need to specify the same Cloud Storage filename.
I understand that you have uploaded the image to Cloud Storage through App Engine via the BlobStore API. To get the actual filename of the original image, you must add the following code in the upload servlet :
Map<String,List<BlobInfo>> uploadInfos = getFileInfos(httpServletRequest);
String theGCSFilename = uploadInfos.get("yourFileName").getGsObjectName();
Note that if you do not want to overwrite the original file, but want to provide a serving URL to the customer, you can either :
Use the ImageService like this :
ImagesService imagesService = ImagesServiceFactory.getImagesService();
String url = imagesService.getServingUrl(ServingUrlOptions.Builder.withGoogleStorageFileName(java));
Create a custom GCSServingServlet
who will use the BlobstoreService.serve()
method to serve a file from the Blobstore or Cloud Storage. In that case, you must check the permissions yourself. Note that you can create a BlobKey
from a GCSFilename
using BlobStoreService.createGSBlobKey()
.
Use the Cloud Storage serving URLs :