I am trying to upload an image to Cloud Storage from Android application.

Followed below link and tried to upload the image .

https://github.com/pliablematter/simple-cloud-storage/blob/master/README.md

But i am getting an error when calling the object insert method.

      StorageObject objectMetadata = new StorageObject(); 
            objectMetadata.setBucket(bucketName); 

        String contentType = URLConnection
                .guessContentTypeFromStream(stream);

        AbstractInputStreamContent content = new InputStreamContent("image/png",
                stream);

        Storage.Objects.Insert insert = storage.objects().insert(
                bucketName, objectMetadata, content);
        insert.setName("MyImage");

        insert.execute(); 

I get the content length as -1 after converting stream to 
InputStreamContent and get the response like

07-27 12:22:10.039: W/System.err(22688): 
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad     
Request07-27 12:22:10.039: W/System.err(22688): Client sent query request with 
a non-empty body.07-27 12:22:10.039: W/System.err(22688):  at 
com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)07-27
 12:22:10.039: W/System.err(22688):  at 
com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)07-27
 12:22:10.039: W/System.err(22688):  at 
com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:432)07-27
 12:22:10.039: W/System.err(22688):  at 
com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)07-27
 12:22:10.039: W/System.err(22688):  at 
com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)07-27
 12:22:10.039: W/System.err(22688):  at 
com.example.rankit_S.CloudStorage.uploadFile(CloudStorage.java:110)

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/225a22bd-787d-4617-b99f-da03e186e112%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to