Using Java8 and aws-java-sdk 1.10.43 I'm trying to get a Pre-Signed URL to an S3 file. I do get back a link, but browsing to it lead to this error:
authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256
To emphasize, I wish to generate a URL that can be sent via email and opened in a browser, not to use Java code to read from that URL.
I'm using the bellow code, and I believe to find out that I need to somehow set setSSEAlgorithm to use "v4", however I've failed to make it work. What am I missing? What should I configure (note: I'm avoiding configuration file on purpose, I wish the code to set all attributes from environment variables)
Date expiration = <some date>;
GeneratePresignedUrlRequest generatePresignedUrlRequest = new GeneratePresignedUrlRequest(bucketName, targetPath);
generatePresignedUrlRequest.setMethod(HttpMethod.GET);
generatePresignedUrlRequest.setExpiration(expiration);
AmazonS3 s3client = new AmazonS3Client(s3Credentials);
URL s = s3client.generatePresignedUrl(generatePresignedUrlRequest);
The bucket is at eu-central-1
Thank you
Using some help I've found the answer, which was a combination of 2 missing pieces (one of which was referred to in the comments):
Need to set this:
Must set the "endPoint" (which was not required for upload or download):
Optionally it might be useful to also add this: