1

I'm trying to send a HTTP GET request of S3 using restTemplate and I get SignatureDoesNotMatch error: The request signature we calculated does not match the signature you provided. Check your key and signing method.

Dose anyone know what can cause this error?

Limor_Sh
  • 31
  • 4
  • I had a problem like this once with presigned s3 urls. Once I went back to the docs, I discovered that I needed to use a specific param in two different places. I was using Boto3 and I needed to set the `acl` in both `Fields` and `Conditions`. Chances are good that reading the docs closely will help a lot. – Garrett Badeau Nov 14 '21 at 16:26
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Nov 17 '21 at 15:08

1 Answers1

1

Found the problem!

Apparently that my question wasn't accurate, just like the error I got from S3 - not indicative.

What I was actually searching for is how to download a file from S3 url using Rest Template. So I had to add the following configuration and used this code to solve it:

RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(new ByteArrayHttpMessageConverter());
HttpHeaders headers = new HttpHeaders();
String url = URLDecoder.decode(path, "UTF-8");
ResponseEntity<byte[]> response = restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(headers), byte[].class);
Limor_Sh
  • 31
  • 4