Skip to content

Commit

Permalink
Merge pull request #3 from silvermine/jrthomer/filter-getobject-params
Browse files Browse the repository at this point in the history
feat: allow for additional params on conditionalPut
  • Loading branch information
jthomerson committed Jun 17, 2020
2 parents e6e042d + ddaf4af commit 30bb876
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions getFileBody.js
@@ -1,8 +1,32 @@
'use strict';

var Q = require('q'),
_ = require('underscore'),
AWS = require('aws-sdk'),
s3 = new AWS.S3();
s3 = new AWS.S3(),
RETAINED_KEYS;

RETAINED_KEYS = [
'Bucket',
'Key',
'IfMatch',
'IfModifiedSince',
'IfNoneMatch',
'IfUnmodifiedSince',
'PartNumber',
'Range',
'RequestPayer',
'ResponseCacheControl',
'ResponseContentDisposition',
'ResponseContentEncoding',
'ResponseContentLanguage',
'ResponseContentType',
'ResponseExpires',
'SSECustomerAlgorithm',
'SSECustomerKey',
'SSECustomerKeyMD5',
'VersionId',
];

/**
* Returns false if a file did not exist, otherwise returns the string or
Expand All @@ -13,7 +37,7 @@ var Q = require('q'),
* not exist
*/
module.exports = function getExistingFileBody(params) {
return Q.ninvoke(s3, 'getObject', params)
return Q.ninvoke(s3, 'getObject', _.pick(params, RETAINED_KEYS))
.then(function(resp) {
return resp.Body;
})
Expand Down

0 comments on commit 30bb876

Please sign in to comment.