use of net.cryptonomica.returns.GetCSuploadURLreturn in project cryptonomica by Cryptonomica.
the class UploadAPI method getCsUploadURL.
@ApiMethod(name = "getCsUploadURL", path = "getCsUploadURL", httpMethod = ApiMethod.HttpMethod.POST)
@SuppressWarnings("unused")
public GetCSuploadURLreturn getCsUploadURL(User googleUser) throws Exception {
CryptonomicaUser cryptonomicaUser = UserTools.ensureCryptonomicaRegisteredUser(googleUser);
//
String imageUploadUrl = BlobstoreServiceFactory.getBlobstoreService().createUploadUrl(// upload handler servlet address
"/cs-user-image-upload", UploadOptions.Builder.withGoogleStorageBucketName(// Cloud Storage bucket name (f.e. "cryptonomica-test.appspot.com")
Constants.GAE_PROJECT_DOMAIN));
String imageUploadKey = randomAlphanumeric(9);
//
cryptonomicaUser.setImageUploadLink(imageUploadUrl);
cryptonomicaUser.setImageUploadKey(imageUploadKey);
//
Key<CryptonomicaUser> cryptonomicaUserKey = ofy().save().entity(cryptonomicaUser).now();
LOG.warning("Upload URL: " + imageUploadUrl);
LOG.warning("Saved for user: " + cryptonomicaUserKey.getName());
LOG.warning("With imageUploadKey: " + imageUploadKey);
return new GetCSuploadURLreturn(imageUploadUrl, imageUploadKey, null);
}
Aggregations