cannot upload to google drive from my android app

丶灬走出姿态 提交于 2020-01-06 05:40:06

问题


I'm writing an adroid app that used to upload a chosen image

to the users' google drive.

I have cloned the code from git to another machine and then the image won't upload any more.

I get a com.google.android.gms.auth.GoogleAuthException: Unknown exception. but it's caught here:

 } catch (IOException e) {
          e.printStackTrace();
        }

      if(fileContent.length() > 5 * 1024 * 1024)
      {
          // Resumable Uploads when the file size exceeds a file size of 5 MB.
          // check link : 
          // 1) https://code.google.com/p/google-api-java-client/source/browse/drive-cmdline-sample/src/main/java/com/google/api/services/samples/drive/cmdline/DriveSample.java?repo=samples&r=08555cd2a27be66dc97505e15c60853f47d84b5a
          // 2) http://stackoverflow.com/questions/15970423/uploading-downloading-of-large-size-file-to-google-drive-giving-error

          AbstractGoogleClientRequest<File> insert = mDriveService.files().insert(body, mediaContent);
          MediaHttpUploader uploader = insert.getMediaHttpUploader();
          uploader.setDirectUploadEnabled(false);
          uploader.setProgressListener(new FileUploadProgressListener());
          destFile = (File) insert.execute();

      }   
      else
      {
          // Else we go by Non Resumable Uploads, which is safe for small uploads.
          destFile = mDriveService.files().insert(body, mediaContent).execute();
      }

Any hints what i can check and verify (maybe missing libraries references?)

I have thought it's because I upload an image from external SD, but even if i choose from local phone SD it throws same exception

来源:https://stackoverflow.com/questions/20908174/cannot-upload-to-google-drive-from-my-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!