curena
12/9/2015 - 7:19 PM

AWS S3 server-side encryption (Non-KMS)

AWS S3 server-side encryption (Non-KMS)

File file = new File(uploadFileName);
PutObjectRequest putRequest = new PutObjectRequest(
                                      bucketName, keyName, file);
            
// Request server-side encryption.
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);     
putRequest.setMetadata(objectMetadata);

PutObjectResult response = s3client.putObject(putRequest);
System.out.println("Uploaded object encryption status is " + 
                  response.getSSEAlgorithm());