protected byte[] hash(InputStream input) throws AmazonClientException {
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
@SuppressWarnings("resource")
DigestInputStream digestInputStream = new SdkDigestInputStream(input, md);
byte[] buffer = new byte[1024];
while (digestInputStream.read(buffer) > -1);
return digestInputStream.getMessageDigest().digest();
} catch (Exception e) {
throw new AmazonClientException("Unable to compute hash while signing request: " + e.getMessage(), e);
}
}