From 9af96af40c11d29185660dbee7178409aa4acda3 Mon Sep 17 00:00:00 2001 From: Mathieu DARTIGUES Date: Wed, 30 Mar 2022 15:55:41 +0200 Subject: [PATCH] Take in consideration other options like the Bucket for remove methods --- index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index b4a475a..19fc2f2 100644 --- a/index.js +++ b/index.js @@ -99,8 +99,17 @@ S3BlobStore.prototype.createWriteStream = function (opts, s3opts, done) { * @param {function(Error)} done callback */ S3BlobStore.prototype.remove = function (opts, done) { - var key = typeof opts === 'string' ? opts : opts.key; - this.s3.deleteObject({ Bucket: this.bucket, Key: key }, done); + var params = {} + if (typeof opts === 'string') { + params.Key = opts; + } else { + opts = Object.assign({}, opts, { + params: Object.assign({}, opts.params) + }); + params.Key = opts.key; + params.Bucket = opts.params.Bucket || this.bucket; + } + this.s3.deleteObject(params, done); return this; };