Compress image before uploading to amazon s3 using AWS sdk in Android
<p>I am  using Android aws sdk 3.2 for uploading images from Android phone to amazon s3, this is working fine but i want to compress image before uploading to amazon s3. </p>

<p>I have explored a lot and found few solutions. </p>

<ol>
<li><p>Compress image on client side and make copy of that file and upload to          S3 after uploading delete that file. </p></li>
<li><p>Compress image on client side and upload that image to EC2 server and   then upload same image to s3 from EC2. </p></li>
</ol>

<p>I am using this code provided by amazon :- </p>

<pre><code>private static AmazonS3Client getS3Client(Context context) {
    if (sS3Client == null) {
        sS3Client = new AmazonS3Client(getCredProvider(context.getApplicationContext()));
    }
    return sS3Client;
}


/**
 * Gets an instance of the TransferUtility which is constructed using the
 * given Context
 *
 * @param context
 * @return a TransferUtility instance
 */
public static TransferUtility getTransferUtility(Context context) {
    if (sTransferUtility == null) {
        sTransferUtility = new TransferUtility(getS3Client(context.getApplicationContext()),
                context.getApplicationContext());
    }


    return sTransferUtility;
}

   private static CognitoCachingCredentialsProvider getCredProvider(Context context) {
    if (sCredProvider == null) {
        sCredProvider = new CognitoCachingCredentialsProvider(
                context.getApplicationContext(),
                Constants.POOL_ID,
                Regions.AP_NORTHEAST_1);
    }
    return sCredProvider;
}


 getTransferUtility(context).upload(
                "bucket name", uuid,
                new File(path)); 
</code></pre>

<p>I want to know does amazon itself provide the facility to compress file then upload or is there a better way of uploading file to s3 after compression? </p>