I am trying to upload an image to amazon (AWS SDK 2.3.0) s3 by using the following code
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
getApplicationContext(),
"XXXXXXX",
// Identity Pool ID
Regions.EU_WEST_1 // Region
);
AmazonS3Client s3Client = new AmazonS3Client(credentialsProvider);
TransferUtility transferUtility = new TransferUtility(s3Client, this.
getApplicationContext());
TransferObserver observer = transferUtility.upload("testbucketzzzz", "test.jpg",
file);
Everytime I try to upload an Image i get the following error
UploadTask: Failed to upload: 37 due to The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256. (Service: Amazon S3; Status Code: 400; Error Code: InvalidRequest; Request ID: 9787E53737D02BA7)
I thought this would only be an issue with older versions of the AWS SDK. After countless hours of trying to fix it I found the following "trick" but this just leads me to another error and shouldn't be needed at all.
System.setProperty(SDKGlobalConfiguration.ENABLE_S3_SIGV4_SYSTEM_PROPERTY, "true");