5

I want to upload and download images and media files from my android application to google cloud store.

When I try a java sample on https://cloud.google.com/storage/docs/json_api/v1/json-api-java-samples

it shows me below errors, Can anyone advice me here, or can anyone show me the links form where do I get help for integrating this to android applications,

[INFO] --- exec-maven-plugin:1.1:java (default-cli) @ storage-cmd-line-sample ---
Jan 22, 2015 10:08:34 AM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for everybody: C:\Users\USER\.store\storage_sample
Jan 22, 2015 10:08:34 AM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for owner: C:\Users\USER\.store\storage_sample
java.lang.NullPointerException
        at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:191)
        at com.google.api.client.util.Preconditions.checkNotNull(Preconditions.java:127)
        at com.google.api.client.json.jackson2.JacksonFactory.createJsonParser(JacksonFactory.java:92)
        at com.google.api.client.json.JsonObjectParser.parseAndClose(JsonObjectParser.java:85)
        at com.google.api.client.json.JsonObjectParser.parseAndClose(JsonObjectParser.java:81)
        at com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:88)
        at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:287)
        at com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:307)
        at com.google.api.client.auth.oauth2.Credential.executeRefreshToken(Credential.java:570)
        at com.google.api.client.auth.oauth2.Credential.refreshToken(Credential.java:489)
        at com.google.api.client.auth.oauth2.Credential.intercept(Credential.java:217)
        at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:859)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
        at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
        at StorageSample.main(StorageSample.java:125)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:290)
        at java.lang.Thread.run(Thread.java:744)

Regards

Pararth
  • 8,114
  • 4
  • 34
  • 51
Bhavin Mistry
  • 185
  • 1
  • 4
  • 13
  • 1
    Does http://stackoverflow.com/questions/18002293/uploading-image-from-android-to-gcs help? – Alex Martelli Jan 22 '15 at 04:52
  • Yes, I checked this link and it seems that a project on this link is working. https://github.com/pliablematter/simple-cloud-storage But can I access my images through URLs? for example this project has a method CloudStorage.downloadFile which downloads it to local folder. But I want to access images using URLs, is it possible? – Bhavin Mistry Jan 22 '15 at 04:57
  • Yup. http://storage.googleapis.com/<>/<> – Ryan Jan 26 '15 at 17:26
  • 3
    @BhavinMistry it seems like you have resolved your issue, can you post your solution as an answer so that other users with the similar issue can benefit from it. Thanks – Faizan Apr 20 '16 at 16:56

1 Answers1

1

As this question still gets many views I will post the user's solution from the comments.

The issue was resolved by following the tutorial at https://github.com/pliablematter/simple-cloud-storage. At the time of this post, that link is 4 years out of date, so a better solution at this time would be to use the updated official sample at https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/storage/json-api.

Cloud storage objects can be accessed via URL in the form https://storage.cloud.google.com/<bucket>/<object>, which is mentioned at various times throughout the documentation.

Adam
  • 5,697
  • 1
  • 20
  • 52