Skip to content

Conversation

jb55
Copy link
Owner

@jb55 jb55 commented Mar 30, 2022

alternative to #26

Signed-off-by: William Casarin jb55@jb55.com

@jb55 jb55 force-pushed the delete-params branch 3 times, most recently from 1cfbb96 to e1b4ceb Compare March 30, 2022 18:24
Signed-off-by: William Casarin <jb55@jb55.com>
S3BlobStore.prototype.remove = function (opts, done) {
var key = typeof opts === 'string' ? opts : opts.key;
this.s3.deleteObject({ Bucket: this.bucket, Key: key }, done);
const params = this.baseParams(opts)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to keep the typeof opts === 'string' test ?

Or test it in the baseParams function ?

As it is mentionned in https://github.com/maxogden/abstract-blob-store#storeremoveopts-cb,
the remove methods accept either a string (and that's the key) or an object.

Comment on lines +61 to +62
const filename = opts.name || opts.filename || params.Key;
let contentType = opts.contentType || mime.lookup(filename)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think filename is already present in params.Key,
as in baseParams function, you assign to params.Key either opts.name, opts.filename or opts.key.

Suggested change
const filename = opts.name || opts.filename || params.Key;
let contentType = opts.contentType || mime.lookup(filename)
const contentType = opts.contentType || mime.lookup(params.Key)

Also, as contentType is defined once, I think const is better than let ?

@mdartic
Copy link

mdartic commented Apr 25, 2022

@jb55 do you want to merge this PR ? or was it just to show how to implement the feature ?

@jb55
Copy link
Owner Author

jb55 commented Apr 26, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants