use of com.example.s3objectlambda.checksum.Checksum in project amazon-s3-object-lambda-default-configuration by aws-samples.
the class GetObjectResponseHandler method writeObjectResponse.
public void writeObjectResponse(HttpResponse<InputStream> presignedResponse, byte[] responseObjectByteArray) {
Checksum checksum;
try {
checksum = this.checksumGenerator.getChecksum(responseObjectByteArray);
} catch (Exception e) {
this.logger.error("Error while writing object response" + e);
writeErrorResponse("Error while writing object response.", Error.SERVER_ERROR);
return;
}
var checksumMap = new HashMap<String, String>();
checksumMap.put("algorithm", checksum.getAlgorithm());
checksumMap.put("digest", checksum.getChecksum());
var checksumObjectMetaData = new ObjectMetadata();
checksumObjectMetaData.setUserMetadata(checksumMap);
this.s3Client.writeGetObjectResponse(new WriteGetObjectResponseRequest().withRequestRoute(event.outputRoute()).withRequestToken(event.outputToken()).withInputStream(new ByteArrayInputStream(responseObjectByteArray)).withMetadata(checksumObjectMetaData).withStatusCode(presignedResponse.statusCode()));
}
Aggregations