Found a few topics that covered the same error in Stackoverlfow, but the scenarios don't match mine. Have an AWS s3 java client program that runs fine on windows in uploading files to an s3 bucket. Now trying to run the same program on a Linux (Ubuntu) server, and getting this error
com.amazonaws.services.s3.model.AmazonS3Exception: The authorization header is malformed; the region 'us-east-1' is wrong; expecting 'eu-west-2' (Service: Amazon S3; Status Code: 400; Error Code: AuthorizationHeaderMalformed; Request ID:
I uploaded the .aws\credentials file from my Windows laptop to the ~/.aws/ directory on the server. Didn't make any changes. I confirmed I had the right credential key after cross-checking with IAM on AWS.
Here's the code (yes, it's hardcoded) that sets the region AmazonS3 s3Client; private static final byte[] BUFFER = new byte[4096 * 1024];
public FileUpload() {
s3Client = AmazonS3ClientBuilder.standard().withRegion("us-east-1").build();
}
I created the bucket manually in the AWS console and it's in the us-east-1 region.
Do I need a config file under ~/.aws ? Don't have one on the Windows laptop