Domanda

I started running into the 30MB filesize limitation when using the cloud storage client API. Upon researching I found the GAE documentation suggesting I use the BlobStore API.

I created an initial test to upload to a bucket in my cloud service. One thing I notice is that the filenames are lost and instead a key is used. No biggie, I now persist the mapping between the blob key and the file metadata I want to store.

I then tried to download the file using the blobstoreService.createGsBlobKey() method. I am passing in the following: "/gs/" + bucketName + "/" + fBlob.getBlobKey()) where fBlob is my mapping object that contains the file info and the blob key.

** Edit ** I also tried using the actual name of the file instead of the blob key (I wasn't quite sure what the documentation was asking for) but the results were the same.

The method getBlobKey() does just that. It returns the string I retrieved from the BlobKey.getKeyString() method.

All seems well until I access the servlet that passes in my parameters to retrieve the file. All of my log dumps look good. Making things more frustrating is that there aren't any errors in the logs. The only indication there is a problem is the generic web page that shows indicating a 500 error has occurred and to post a message in the support forum if I continue to encounter this error.

So here I am :)

Any assistance would be greatly appreciated. I would provide more info (i.e. stack traces) but as I mentioned there aren't any. Here is a summary of the servlet:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws     ServletException, IOException {
    String iopsKey = request.getParameter("iopsId");
    String itemId = request.getParameter("itemId");
    String digitalId = request.getParameter("resourceId");

    Logger.getAnonymousLogger().info("Site Id: " + iopsKey);
    Logger.getAnonymousLogger().info("Item Id: " + itemId);
    Logger.getAnonymousLogger().info("Digital Good Id: " + digitalId);

    final DigitalResource resource = delegate.getDigitalResource(iopsKey, itemId, digitalId);
    Logger.getAnonymousLogger().info("Contents of Digital Resource: " + resource);

    FileBlobMap fBlob = delegate.findBLOBByFilename(resource.getInternalName());
    Logger.getAnonymousLogger().info("Contents of FileBlogMap: " + fBlob);

    BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
    BlobKey blobKey = blobstoreService.createGsBlobKey("/gs/vendor-imports/" + fBlob.getBlobKey());

    blobstoreService.serve(blobKey, response);
}

Edit #2 ** After some playing around I realize that the key/name generated by the blobstore API does not seem to correlate with what is actually stored in the cloud storage.

When using the blobstore api I am aware of only 2 fields that would be useful in mapping back to the stored file: The key string from the blob key object and the actual name of the file. However, the name/key value that is created in the cloud storage is yet another key string and doesn't seem to match anything AFAIK.

Now if I copy the key/name from the cloud store and hard code it to my object that stores the filename/blobkey mapping via the DataStore Viewer then everything works! So it seems that there is a disconnect between the reference in the cloud store and what I am getting in my call back handler.

Resolved ** There is an additional method that is part of the FileInfo object I was using that I had not noticed. This method is called getGsObjectName() and it returns a fully mapped string that includes the "/gs/" prefix already along with the token string I see in the cloud store. This wasn't immediately obvious to me so hopefully this post will save someone else's time in the future.

È stato utile?

Soluzione 2

Resolved ** There is an additional method that is part of the FileInfo object I was using that I had not noticed. This method is called getGsObjectName() and it returns a fully mapped string that includes the "/gs/" prefix already along with the token string I see in the cloud store. This wasn't immediately obvious to me so hopefully this post will save someone else's time in the future.

Sorry if my formatting is off and the fact that I have "solutions" in multiple places. This is my first time posting so and I got a little ahead of myself.

Altri suggerimenti

I think you might have problems with creating the blobKey. Your fBlob.getBlobKey() already returns blobKey but then you try to put it into another blobKey. Did you try just passing that key into blobstoreService.serve method:

blobstoreService.serve(fBlob.getBlobKey(), response);

Also your generic page that you see is the error page served by AppEngine when there is a server error. You should check your console for any exceptions. If you're running in production you can check logs in AppEngine console to see the details of the error.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top