title: Upload a video to Youtube using Java
body: <p>I am trying to upload a video to YouTube using the <a href="https://github.com/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/UploadVideo.java" rel="nofollow">YouTube API</a>. While running tests using unchanged code the following exception was thrown:</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalArgumentException: Cannot call getProgress() if the specified AbstractInputStreamContent has no content length. Use  getNumBytesUploaded() to denote progress instead.
  at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkArgument(Preconditions.java:92)
  at com.google.api.client.util.Preconditions.checkArgument(Preconditions.java:49)
  at com.google.api.client.googleapis.media.MediaHttpUploader.getProgress(MediaHttpUploader.java:934)
  at com.google.api.services.samples.youtube.cmdline.UploadVideo$1.progressChanged(UploadVideo.java:151)
  at com.google.api.client.googleapis.media.MediaHttpUploader.updateStateAndNotifyListener(MediaHttpUploader.java:907)
  at com.google.api.client.googleapis.media.MediaHttpUploader.resumableUpload(MediaHttpUploader.java:471)
  at com.google.api.client.googleapis.media.MediaHttpUploader.upload(MediaHttpUploader.java:336)
  at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:427)
  at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
  at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
  at com.google.api.services.samples.youtube.cmdline.UploadVideo.main(UploadVideo.java:165)
  </code></pre>
  
  <p>Any idea why and how may I fix it?</p>