title: Dropbox ChunkedUpload
body: <p>I'm trying to implement chunked upload to Dropbox.
  I've written a code based on the example from the Dropbox API documentation, but it fails.</p>
  
  <p>The following code throws that exception:</p>
  
  <blockquote>
    <p>com.dropbox.client2.exception.DropboxIOException: Apache HTTPClient
    encountered an error. No response, try again.     at
    com.dropbox.client2.RESTUtility.execute(Unknown Source)   at
    com.dropbox.client2.DropboxAPI$ChunkedUploadRequest.upload(Unknown
    Source)   at
    com.dropbox.client2.DropboxAPI$ChunkedUploader.upload(Unknown Source)
      at com.dropbox.client2.DropboxAPI$ChunkedUploader.upload(Unknown
    Source)</p>
  </blockquote>
  
  <p>Here is the code:</p>
  
  <pre><code>/** Uploads content to Dropbox.
   * @param dropbox An already linked dropbox API
   * @param stream The stream to upload
   * @param length The number of bytes to upload
   * @param path The path where to store the uploaded content
   * @return a boolean, false if the upload was cancelled, true if it completes 
   * @throws IOException
   * @throws DropboxException
   */
  public static boolean upload(DropboxAPI&lt;?&gt; dropbox, InputStream stream,
          long length, String path) throws IOException, DropboxException {
      // Create a chunked uploader
      ChunkedUploader uploader = dropbox.getChunkedUploader(stream, length);
      try {
          int tryCounter = 1;
          while (!uploader.isComplete()) {
              try {
                  uploader.upload(); // The exception occurs on this line
              } catch (DropboxException e) {
                  tryCounter++;
                  if (tryCounter &gt; 5) throw e; // Give up after a while.
                  System.err.println ("Upload failed, trying again ...");
                  try {
                      Thread.sleep(1000);
                  } catch (InterruptedException e1) {
                  }
              }
          }
      } catch (DropboxPartialFileException e) {
          // Upload was cancelled
          return false;
      }
      // If the upload completes, determine the current revision of the path.
      String parentRev = null;
      try {
          Entry metadata = dropbox.metadata(path, 1, null, false, null);
          parentRev = metadata.rev;
      } catch (DropboxServerException e) {
          // If the error is not a FileNotFound error =&gt; It's really an error
          if (e.error!=DropboxServerException._404_NOT_FOUND) throw e;
      }
      // Finish the upload
      uploader.finish(path, parentRev);
      return true;
  }
  </code></pre>
  
  <p>Any idea of what I'm doing wrong?</p>
  
  <p>PS : Of course, I verified that other api functions are ok with the DropboxAPI instance I pass to that method.</p>