我正在嘗試使用 restTemplate 發送 S3 的 HTTP GET 請求,但出現 SignatureDoesNotMatch 錯誤:我們計算的請求簽名與您提供的簽名不匹配。檢查您的密鑰和簽名方法。
有誰知道什么會導致這個錯誤?
uj5u.com熱心網友回復:
發現問題了!
顯然,我的問題不準確,就像我從 S3 得到的錯誤一樣 - 不是指示性的。
我實際搜索的是如何使用 Rest Template 從 S3 url 下載檔案。所以我不得不添加以下配置并使用此代碼來解決它:
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);
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/364262.html
標籤:http 网址 得到 要求 spring-resttemplate
