I am trying to store user photo uploads in Google Cloud Storage but running into issues with the call:
blobStoreService.createUploadUrl(...)
I need to track which user Id is associated with the uploaded file. If the user's ID is 1234, I need to store that as metadata on the Cloud Storage file.
I can add metadata when I create the Cloud Storage file directly:
GSFileOptionsBuilder optionsBuilder = new GSFileOptionsBuilder()
.setBucket("myBucket")
.setKey(key) // path...
.addUserMetadata("userId", "1234");
But I really want to use the GAE provided BlobStoreService.createUploadUrl(...) because it supports larger files than this code above can handle. Is it at all possible to specify metadata with the createUploadUrl? Or is it even possible to find out which google storage key/filename is created?
Update I already have the blobKey from the upload callback serlvet. However, I can't find a way to add metadata to the Google Storage file assocated with this blobKey. At least locally, it thinks it is a BlobStore entry, not a GS file
// get the key:
Map<String, List<BlobKey>> blobKeysFromPost=BlobstoreServiceFactory.getBlobstoreService().getUploads(request);
// pull out the blobKey generated from the recently submitted POST
BlobKey blobKey = ...
// Now how do I access the cloud storage entry for this key? I tried:
AppEngineFile file = FileServiceFactory.getFileService().getBlobFile(blobKey);
// But this file locally returns "blobstore":
file.getFileSystem().getName(); // Should be GS.