Google App Engine - ImagesService.getServingUrl()

2019-08-23 05:24发布

I'm receiving an image file through a HTTP request and storing it in the Blobstore. My code is along the lines of that found here: [https://developers.google.com/appengine/docs/java/blobstore/overview#Writing_Files_to_the_Blobstore][1].

When calling the function ImagesService.getServingUrl() on the blobkey for the image I had stored I get the message below:

HTTP ERROR 500

Problem accessing /upload. Reason:

    Failed to read image
Caused by:

java.lang.IllegalArgumentException: Failed to read image
    at com.google.appengine.api.images.ImagesServiceImpl.getServingUrl(ImagesServiceImpl.java:282)

After hours of googling, trying to find a solution, I think that the problem is that the function closeFinally() is faulty. I think this because after closing the new blob image that I make, the FileStats object associated with the blob returns false for the hasFinalizedName(). Yet the blob returns true for isClosed() and isFinalized(). Also, its full path is something like this:

/blobstore/writable:xFSAF_493dsfAfw489vFa...

If it is closed it shouldn't be writable, I think.

So my questions are: Does anyone have a solution to the getServingUrl not working? Does anyone have a workaround getServingUrl? I want to have pictures to serve to users and I want these pictures to exist as static files. getServingUrl with blobstore seems to be the best choice for me. I don't want to use Google Cloud Storage because for every Blobstore vs Google Cloud Storage question I saw, Blobstore won it seemed.

0条回答
登录 后发表回答