title: Drive V3 API : java.lang.IllegalArgumentException
body: <p>This is how I create  "AbstractInputStreamContent" from inputstream of file:</p>
  
  <pre><code>final Long length = Long.valueOf(filesData.get(uploadedFileName).get("size")).longValue();
      final InputStream fileStream = item.openStream(); //FileItemStream item
      AbstractInputStreamContent fileContent = new AbstractInputStreamContent(uploadedFileMimeType) {
          @Override
          public boolean retrySupported() {
              return false;
          }
          @Override
          public long getLength() throws IOException {
              return length;
          }
          @Override
          public InputStream getInputStream() throws IOException {
              return fileStream;
          }
      };
  </code></pre>
  
  <p>And "InputStreamContent" as:</p>
  
  <pre><code>InputStreamContent fileContent = new InputStreamContent(uploadedFileMimeType, item.openStream());
  fileContent.setLength(Long.valueOf(filesData.get(uploadedFileName).get("size")).longValue());
  </code></pre>
  
  <p>To replace old file with new file I use(both files are of .docx format):</p>
  
  <pre><code>Drive.Files.Update update = driveService.files().update(fileIdOfFileToReplace,fileMeta,fileContent);
          update.set("uploadType", "resumable");
          update.getMediaHttpUploader().setDirectUploadEnabled(false);
          update.getMediaHttpUploader().setChunkSize(MediaHttpUploader.DEFAULT_CHUNK_SIZE);
          File updatedFile = update.execute();
  </code></pre>
  
  <p>Uploading a new file works fine whether I use InputStreamContent or AbstractInputStreamContent. <strong>But update gives "java.lang.IllegalArgumentException" with both</strong></p>
  
  <pre><code>java.lang.IllegalArgumentException
      at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkArgument(Preconditions.java:111)
      at com.google.api.client.util.Preconditions.checkArgument(Preconditions.java:37)
      at com.google.api.client.googleapis.media.MediaHttpUploader.setInitiationRequestMethod(MediaHttpUploader.java:872)
      at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.initializeMediaUpload(AbstractGoogleClientRequest.java:237)
      at com.google.api.services.drive.Drive$Files$Update.&lt;init&gt;(Drive.java:3163)
      at com.google.api.services.drive.Drive$Files.update(Drive.java:3113)
      at com.util.DocumentsUtil.updateFile(DocumentsUtil.java:22)
      at com.controllers.collab.documents.Documents.fileUpload(Documents.java:165)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:44)
      at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
      at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
      at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
  </code></pre>