title: Resumable upload using Drive API for Android
body: <p>I want to upload large files (>10Mb) to Google Drive, using the drive api. It is working fine with smaller files (when there's good wifi), using direct upload:</p>
  
  <pre><code>Drive.Files.Insert insert = driveService.files().insert(fileMetadata, mediaContent);
  MediaHttpUploader uploader = insert.getMediaHttpUploader();
  uploader.setChunkSize(UPLOAD_CHUNK_SIZE);
  uploader.setDirectUploadEnabled(true);
  insert.execute();
  </code></pre>
  
  <p>Now, suppose we are uploading a larger file. We want to keep track of the connection, so we use resumable upload, given by MediaHttpUploader method...</p>
  
  <pre><code>uploader.setDirectUploadEnabled(false);
  uploader.setProgressListener(new MediaHttpUploaderProgressListener() {
      @Override
      public void progressChanged(MediaHttpUploader mediaHttpUploader) throws IOException {
          switch (mediaHttpUploader.getUploadState()) {
              case INITIATION_STARTED:     break;
              case INITIATION_COMPLETE:  break;
              case MEDIA_IN_PROGRESS:   break;
              case MEDIA_COMPLETE:        break;
          }
      }
  });
  </code></pre>
  
  <p>Ok. But there is no state for <strong>MEDIA_FAILED</strong>, am I correct? And what can I do when the upload does not reach <strong>MEDIA_COMPLETE</strong>? </p>
  
  <p>Also, I found no method to resume the upload. So even if a 100Mb upload is at 90% and fails, all I can do is start it all over again??</p>
  
  <p><em>PS: this issue has been reported before without success
  <a href="https://stackoverflow.com/questions/13580109/check-progress-for-upload-download-google-drive-api-for-android-or-java">Check progress for Upload &amp; Download (Google Drive API for Android or Java)</a>
  <a href="https://stackoverflow.com/questions/19349405/android-google-drive-resumable-upload-fails-very-often">Android Google Drive Resumable Upload fails very often</a></em></p>