title: Android file upload to Amazon S3
body: <p>I want to upload images to my s3 bucket. I tried different solution to upload file such as <a href="https://www.studytutorial.in/android-application-integrate-to-amazon-s3-tutorial" rel="nofollow noreferrer">this tutorial</a> but I always get error as ssl exception :</p>
  
  <blockquote>
    <p>Unable to execute HTTP request: Write error: ssl=0x55a53d5240: I/O error during system call, Connection reset by peer</p>
  </blockquote>
  
  <p>I found one comment about this exception Comment is if your network bad you can get on error. But my network is good.</p>
  
  <p>My code is below:</p>
  
  <pre><code>private void uploadImage() {
  
      // Initialize the Amazon Cognito credentials provider
      CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
              getContext().getApplicationContext(),
              "us-west-2:************", // Identity Pool ID
              Regions.US_WEST_2 // Region
      );
  
  
      ClientConfiguration configuration = new ClientConfiguration();
      configuration.setConnectionTimeout(50000);
      configuration.setSocketTimeout(300000);
  
      final AmazonS3 s3 = new AmazonS3Client(credentialsProvider, configuration);
  
      TransferUtility transferUtility = new TransferUtility(s3, getContext().getApplicationContext());
  
      LocalImage image = mAddImageAdapter.getLocalImage(0);
      final File mFile = new File(image.getImagePath());
      long len = mFile.length();
  
      transferUtility.upload("2y1s-images", mFile.getName(), mFile).setTransferListener(new TransferListener() {
          @Override
          public void onStateChanged(int id, TransferState state) {
  
              Log.i(TAG, "image upload state: " + state.name());
          }
  
          @Override
          public void onProgressChanged(int id, long bytesCurrent, long bytesTotal) {
  
  
              Log.e(TAG, "image upload percentage: " + bytesCurrent + " -" + bytesTotal);
          }
  
          @Override
          public void onError(int id, Exception ex) {
  
              Log.e(TAG, "image upload error: " + ex.getMessage());
          }
      });
  
  
  }
  </code></pre>