Stefan Perlic
Stefan Perlic

Reputation: 36

AWS S3 response FAILED, even though file is fully uploaded

I'm just trying to upload an image to S3 via an Android app. What I concluded so far is that images that are bigger than 5MB are uploaded without a problem, however, images that are smaller than 5MB are FULLY UPLOADED and can be downloaded from S3 manually, however, the response i get is FAILED. I just want to remind you that 5MB is the bottom threshold for issuing a multipart request (SDK uploads using multipart automatically when the file is above 5MB, I checked this in their code).

I also checked the md5 sum by hand, and the sums from two files (uploaded and selected for upload) MATCH.

I tested uploading small images using a AWS S3 CLI and it works without a problem.

This is the exception I get:

AmazonClientException: Unable to verify integrity of data upload. Client calculated content hash didn't match hash calculated by Amazon S3. You may need to delete the data stored in Amazon S3.

These are the libraries I am using:

com.amazonaws:aws-android-sdk-s3:$version

com.amazonaws:aws-android-sdk-mobile-client:$version

Any help would be much appreciated.

Upvotes: 0

Views: 2096

Answers (1)

Stefan Perlic
Stefan Perlic

Reputation: 36

Basically, the problem was that bucket where images were uploaded was encrypted, as soon as we created a new unencrypted bucket, the uploads were fine. It seems that hash of two files was different because one hash calculation was done on an encrypted file and one on an unencrypted file. It seems (although I'm not completely sure) that multipart request just bypasses the md5 checksum check.

Important to mention, this was only happening while using the Android SDK, the iOS one works fine (don't know what are the exact differences in implementation, I could maybe update on that later).

It worked for months before the encryption was introduced.

I will investigate this issue further and notify AWS support if there is a reason for that.

Upvotes: 1

Related Questions