使用应用程序android将图像上传到谷歌云存储

我正在尝试将aN图像上传到Google云端存储。
我找到了一个像https://github.com/pliablematter/simple-cloud-storage这样的例子来解释如何做到这一点。
我创建了一个项目桶等,但是当我尝试创建客户端ID时,我收到此错误:

发生了错误。 请稍后重试 在此处输入图像描述

这个错误来自哪里?
也许还有另一种方法可以使用Android应用程序将文件上传到谷歌云存储?

_______________________________EDIT___________________________________________在新的控制台中,我可以看到一条消息,告诉我只有项目的所有者可以为应用程序Web和帐户服务创建客户端。 因此,错误是因为我与帐户colaborator连接

在此处输入图像描述 _________________________________EDITAN___________________________________现在我可以创建客户端ID,但我不知道如何将文件从android上传到存储桶,我读了这个https://github.com/pliablematter/simple-cloud-storage但它适用于java而不是Android,任何人都有一个例子我怎么能这样做?

任何帮助将不胜感激

我最终可以像这样在谷歌存储上传图像

class RetrieveFeedTask extends AsyncTask { private Exception exception; protected String doInBackground(Void... params) { try { List scopes = new ArrayList(); scopes.add(StorageScopes.DEVSTORAGE_FULL_CONTROL); httpTransport= new com.google.api.client.http.javanet.NetHttpTransport(); //agarro la key y la convierto en un file AssetManager am = getAssets(); String STORAGE_SCOPE = "https://www.google.com/analytics/feeds/" ; InputStream inputStream = am.open("*********114db0.p12"); //you should not put the key in assets in prod version. //convert key into class File. from inputstream to file. in an aux class. File file =stream2file(inputStream); //Google Credentianls GoogleCredential credential = new GoogleCredential.Builder().setTransport(httpTransport) .setJsonFactory(JSON_FACTORY) .setServiceAccountId("**********ic1bgevf3h@developer.gserviceaccount.com") .setServiceAccountScopes((scopes)) .setServiceAccountPrivateKeyFromP12File(file) .build(); String URI = "https://storage.googleapis.com/" + "BUCKET_NAME"+"/"+"zzzzz3"+".jpg"; HttpRequestFactory requestFactory = httpTransport.createRequestFactory(credential); GenericUrl url = new GenericUrl(URI); //byte array holds the data, in this case the image i want to upload in bytes. Resources res = getResources(); Drawable drawable = res.getDrawable(R.drawable.camera); Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); byte[] bitMapData = stream.toByteArray(); HttpContent contentsend = new ByteArrayContent("image/jpeg", bitMapData ); HttpRequest putRequest; putRequest = requestFactory.buildPutRequest(url, contentsend); com.google.api.client.http.HttpResponse response = putRequest.execute(); String content = response.parseAsString(); Log.d("debug", "response is:"+response.getStatusCode()); Log.d("debug", "response content is:"+content); } catch (IOException | GeneralSecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ""; } protected void onPostExecute(String feed) { int i = 0; int j = i; // TODO: check this.exception // TODO: do something with the feed } } 

不要忘记下载jar并将其放在lib文件夹中: – com.fasterxml.jackson.core.jar – google-api-client-1.20.0.jar – google-api-services-storage-v1beta2-rev21-1.15 .0-rc.jar – google-http-client-1.20.0.jar – google-http-client-jackson2-1.20.0.jar – google-http-client-jdo-1.20.0.jar – google-oauth -client-1.20.0.jar