谷歌云存储的Android示例

我想从我的
Android应用程序上传和下载图像和媒体文件到谷歌云商店.

当我在https://cloud.google.com/storage/docs/json_api/v1/json-api-java-samples上尝试java样本时

它显示我下面的错误,
任何人都可以在这里建议我,或者任何人都可以告诉我链接表单我在哪里获得帮助将其集成到Android应用程序,

[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)

问候

最佳答案 由于这个问题仍然有很多观点,我将从评论中发布用户的解决方案.

该问题在https://github.com/pliablematter/simple-cloud-storage之后按照教程解决.在本文发布时,该链接已过时4年,因此目前更好的解决方案是使用https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/storage/json-api更新的官方样本.

可以通过URL访问云存储对象,格式为https://storage.cloud.google.com/\u0026lt;bucket\u0026gt;/\u0026lt;object\u0026gt ;,这在整个documentation的不同时间都会提到.

点赞