public static String getNotFoundUrl(int size) {
try {
BlobKey blob_key = BLOB_STORE.createGsBlobKey("/gs/web_content/placeholder_img.png");
// Simple Test to make sure blob_key points at the right thing.
byte[] image_data = BLOB_STORE.fetchData(blob_key, 0, 100);
Application.getLogger().warning(new String(image_data));
// This parts works and gets the first 100 bytes.
ServingUrlOptions opts = ServingUrlOptions.Builder.withBlobKey(blob_key);
if(size > 0) opts.imageSize(size);
return IMAGES_SERVICE.getServingUrl(opts);
} catch(IllegalArgumentException e) {
Application.getLogger().warning("Unable to serve placeholder image from Cloud Storage.");
Application.getLogger().warning(e.getMessage());
Application.logException(e);
return "/placeholder_img.png";
}
}
The fetchData call succeeds and I successfully read the first 100 bytes of the file that way. But the getServingUrl fails with IllegalArgumentException.
java.lang.IllegalArgumentException:
at com.google.appengine.api.images.ImagesServiceImpl.getServingUrl(ImagesServiceImpl.java:282)
Any ideas on why this happens will be much appreciated.