diff --git a/lib/index.js b/lib/index.js index 526f5f1..06fae2d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -137,6 +137,7 @@ Client.prototype.uploadFile = function(params) { var defaultContentType = params.defaultContentType || 'application/octet-stream'; s3Params.ContentType = mime.lookup(localFile, defaultContentType); } + var sse = s3Params.ServerSideEncryption; var fatalError = false; var localFileSlicer = null; var parts = []; @@ -222,7 +223,7 @@ Client.prototype.uploadFile = function(params) { Key: encodeSpecialCharacters(s3Params.Key), SSECustomerAlgorithm: s3Params.SSECustomerAlgorithm, SSECustomerKey: s3Params.SSECustomerKey, - SSECustomerKeyMD5: s3Params.SSECustomerKeyMD5, + SSECustomerKeyMD5: s3Params.SSECustomerKeyMD5 }; queueAllParts(data.UploadId, multipartUploadSize); }); @@ -315,11 +316,13 @@ Client.prototype.uploadFile = function(params) { } pend.wait(function() { if (fatalError) return; - if (!compareMultipartETag(data.ETag, multipartETag)) { - errorOccurred = true; - uploader.progressAmount -= overallDelta; - cb(new Error("ETag does not match MD5 checksum")); - return; + if (sse !== 'aws:kms') { + if (!compareMultipartETag(data.ETag, multipartETag)) { + errorOccurred = true; + uploader.progressAmount -= overallDelta; + cb(new Error("ETag does not match MD5 checksum")); + return; + } } part.ETag = data.ETag; cb(null, data); @@ -411,9 +414,11 @@ Client.prototype.uploadFile = function(params) { } pend.wait(function() { if (fatalError) return; - if (!compareMultipartETag(data.ETag, localFileStat.multipartETag)) { - cb(new Error("ETag does not match MD5 checksum")); - return; + if (sse !== 'aws:kms') { + if (!compareMultipartETag(data.ETag, localFileStat.multipartETag)) { + cb(new Error("ETag does not match MD5 checksum")); + return; + } } cb(null, data); }); @@ -507,9 +512,11 @@ Client.prototype.downloadFile = function(params) { handleError(new Error("Downloaded size does not match Content-Length")); return; } - if (eTagCount === 1 && !multipartETag.anyMatch(eTag)) { - handleError(new Error("ETag does not match MD5 checksum")); - return; + if (headers['x-amz-server-side-encryption'] !== 'aws:kms' ) { + if (eTagCount === 1 && !multipartETag.anyMatch(eTag)) { + handleError(new Error("ETag does not match MD5 checksum")); + return; + } } cb(); }); @@ -825,9 +832,11 @@ Client.prototype.downloadBuffer = function(s3Params) { handleError(new Error("Downloaded size does not match Content-Length")); return; } - if (eTagCount === 1 && !multipartETag.anyMatch(eTag)) { - handleError(new Error("ETag does not match MD5 checksum")); - return; + if (headers['x-amz-server-side-encryption'] !== 'aws:kms' ) { + if (eTagCount === 1 && !multipartETag.anyMatch(eTag)) { + handleError(new Error("ETag does not match MD5 checksum")); + return; + } } cb(); });