From f467d964a7f19a132b77a20b9a3c648f6278ab7f Mon Sep 17 00:00:00 2001 From: Timo Wolf Date: Sun, 8 Oct 2017 18:00:46 +0200 Subject: [PATCH] add AWS S3 options for server side encryption Now, the AWS S3 options for server side encryptions are passed to the upload handler. Thus, the client can specify the AWS options and use AWS Server Side Encryption. --- lib/storage-handler.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/storage-handler.js b/lib/storage-handler.js index 2c42bac..0abc0b6 100644 --- a/lib/storage-handler.js +++ b/lib/storage-handler.js @@ -166,6 +166,30 @@ exports.upload = function(provider, req, res, options, cb) { uploadParams.acl = file.acl; } + // add AWS specific options + // See http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property + if (options.StorageClass) { + uploadParams.StorageClass = options.StorageClass; + } + if (options.CacheControl) { + uploadParams.CacheControl = options.CacheControl; + } + if (options.ServerSideEncryption) { + uploadParams.ServerSideEncryption = options.ServerSideEncryption; + } + if (options.SSEKMSKeyId) { + uploadParams.SSEKMSKeyId = options.SSEKMSKeyId; + } + if (options.SSECustomerAlgorithm) { + uploadParams.SSECustomerAlgorithm = options.SSECustomerAlgorithm; + } + if (options.SSECustomerKey) { + uploadParams.SSECustomerKey = options.SSECustomerKey; + } + if (options.SSECustomerKeyMD5) { + uploadParams.SSECustomerKeyMD5 = options.SSECustomerKeyMD5; + } + var writer = provider.upload(uploadParams); writer.on('error', function(err) {