Search in sources :

Example 1 with GetCSuploadURLreturn

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);
}
Also used : GetCSuploadURLreturn(net.cryptonomica.returns.GetCSuploadURLreturn) CryptonomicaUser(net.cryptonomica.entities.CryptonomicaUser) ApiMethod(com.google.api.server.spi.config.ApiMethod)

Aggregations

ApiMethod (com.google.api.server.spi.config.ApiMethod)1 CryptonomicaUser (net.cryptonomica.entities.CryptonomicaUser)1 GetCSuploadURLreturn (net.cryptonomica.returns.GetCSuploadURLreturn)1