Reputation: 57
We are working on an upload process that gets a presigned url from the server to use for uploading files to our s3 bucket. Our request is being built like so
GeneratePresignedUrlRequest gpur = new GeneratePresignedUrlRequest(bucketName, file);
gpur.setMethod(HttpMethod.PUT);
gpur.setExpiration(expiration);
//gpur.setSSEAlgorithm(SSEAlgorithm.getDefault().getAlgorithm());
url = client.generatePresignedUrl(gpur);
and being consumed like so
$http({
method: 'PUT',
url: gpur url,
transformRequest: angular.identity,
uploadEventHandlers: {progress: function(progress) {
file.uploadProgress = Math.round(progress.loaded / progress.total * 100);
}},
data: file,
})
which works great. The file gets moved to the bucket no problem. However, when we add gpur.setSEEAlgorithm(SSEAlgorithm.getDefault().getAlgorithm())
back in, we get a "SignatureDoesNotMatch" error. What we don't understand about the error is that in the <CanonicalRequest>
tags, the value of x-amz-server-side-encryption
is blank.
Is there something obvious we're missing here?
EDIT: After a bit of researching I found a similar question here: https://salesforce.stackexchange.com/questions/114544/amazon-s3-specifying-sse-s3-with-pre-signed-urls-usingapex
I added
headers:{
'X-Amz-Server-Side-Encryption': 'AES256',
},
to the request and it works, although it seems to be case sensitive.
Upvotes: 2
Views: 160
Reputation: 57
Adding my edit as an answer. :)
After a bit of researching I found a similar question here: https://salesforce.stackexchange.com/questions/114544/amazon-s3-specifying-sse-s3-with-pre-signed-urls-usingapex
I added
headers:{ 'X-Amz-Server-Side-Encryption': 'AES256', }, to the request and it works, although it seems to be case sensitive
Upvotes: 1