Skip to content

Commit 73b5817

Browse files
committed
remove: use params helper like the other functions
Signed-off-by: William Casarin <jb55@jb55.com>
1 parent a1e52be commit 73b5817

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

index.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,34 @@ S3BlobStore.prototype.createReadStream = function (opts) {
4141
return stream;
4242
};
4343

44-
S3BlobStore.prototype.uploadParams = function (opts) {
44+
S3BlobStore.prototype.baseParams = function (opts) {
4545
opts = Object.assign({}, opts, {
4646
params: Object.assign({}, opts.params)
4747
});
4848

49-
var filename = opts.name || opts.filename;
50-
var key = opts.key || filename;
51-
var contentType = opts.contentType;
49+
const filename = opts.name || opts.filename;
50+
const key = opts.key || filename;
51+
let params = opts.params;
5252

53-
var params = opts.params;
5453
params.Bucket = params.Bucket || this.bucket;
5554
params.Key = params.Key || key;
5655

57-
if (!contentType) {
58-
contentType = filename ? mime.lookup(filename) : mime.lookup(opts.key);
59-
}
60-
if (contentType) params.ContentType = contentType;
56+
return params
57+
}
58+
59+
S3BlobStore.prototype.uploadParams = function (opts) {
60+
const params = this.baseParams(opts)
61+
const filename = opts.name || opts.filename || params.Key;
62+
let contentType = opts.contentType || mime.lookup(filename)
63+
64+
if (contentType)
65+
params.ContentType = contentType
6166

6267
return params;
6368
};
6469

6570
S3BlobStore.prototype.downloadParams = function (opts) {
66-
var params = this.uploadParams(opts);
67-
delete params.ContentType;
68-
return params;
71+
return this.baseParams(opts);
6972
};
7073

7174
/**
@@ -99,8 +102,8 @@ S3BlobStore.prototype.createWriteStream = function (opts, s3opts, done) {
99102
* @param {function(Error)} done callback
100103
*/
101104
S3BlobStore.prototype.remove = function (opts, done) {
102-
var key = typeof opts === 'string' ? opts : opts.key;
103-
this.s3.deleteObject({ Bucket: this.bucket, Key: key }, done);
105+
const params = this.baseParams(opts)
106+
this.s3.deleteObject(params, done);
104107
return this;
105108
};
106109

0 commit comments

Comments
 (0)