title: Upload file to Amazon S3 from Android slow
body: <p>I have implemented the file upload to Amazon S3 following the Amazon guide and I have noticed that it is too slow. It takes around 10 sec to upload a simple png file around 20kb.</p>
  
  <p>Initially I thought that the problem was related with threads and I have implemented an AsyncTask to upload the image, but the problem is still there. Following is the code employed to upload the image. </p>
  
  <pre><code>private class UploadFileTask extends AsyncTask&lt;String, Integer, String&gt; {
      String remotePath;
      String remoteFileName;
      File file;
      Context context;
      S3UploadInterface listener;
  
  
      public UploadFileTask(Context context,String remotePath,String remoteFileName, File file, S3UploadInterface listener){
          this.context=context;
          this.remotePath=remotePath;
          this.remoteFileName=remoteFileName;
          this.file=file;
          this.listener=listener;
      }
  
      protected String doInBackground(String... params) {
          credentialsProvider = new CognitoCachingCredentialsProvider(context,
                  "MY_PRIVATE_CREDENTIAL",
                  Regions.US_EAST_1);
          TransferManager transferManager = new TransferManager(credentialsProvider);
          Upload upload = transferManager.upload(remotePath, remoteFileName, file);
          TransferProgress transferred = upload.getProgress();
          while (!upload.isDone()) {
              try {
                  publishProgress((int) transferred.getPercentTransferred());
              } catch (Exception e) {
                  listener.uploadFailed(e);
              }
          }
          return "uploaded";
      }
  
      protected void onProgressUpdate(Integer... progress) {
          if (listener!=null)
              listener.currentUploadProgress(progress[0]);
      }
  
      protected void onPostExecute(String result) {
          if (listener!=null)
              listener.uploadCompleted();
      }
  }
  </code></pre>
  
  <p>Any idea to solve this problem?
  Thanks :)</p>