digitalnodecom / node-red-contrib-generic-s3

Generic S3 nodes for use in Node-RED
https://www.npmjs.com/package/@digitalnodecom/node-red-contrib-generic-s3
Apache License 2.0
3 stars 5 forks source link

Put Object (if changed) #8

Closed trajche closed 1 year ago

trajche commented 1 year ago

For Buckets that have enabled Versioning, it would be useful to have a "Upsert Object" (insert or update).

Currently, if you do a Put Object it will add a new Version of the object no matter if it's the same contents. The goal would be to check the contents and compare.

There are two ways that comparison could be done:

The S3 ETAG is also a MD5 calculation, but only for non-multipart files. Not sure how it works for multipart uploads.

rristov60 commented 1 year ago

This issue is closed with #13 . Upon item insertion, first MD5 hash is calculated for the body of the item, and it is compared to the current ETag for the object if the object already exists. If they don't match, it means that the contents of the file are changed and the object is put. If versioning is enabled, and the object exists, new version of it will be created. This is both for Put Object and Put Objects. Please note that this is valid only for objects that have MD5 ETags. If the ETags are not MD5, each time the object will be inserted. More details about ETags can be found here.

trajche commented 1 year ago

Re-opening this one, as it seems to overwrite files after the 1.3.0 release.

trajche commented 1 year ago

Btw, in order to allow for speed, perhaps there can be a property/checkbox (Upsert - Only Put Object if the MD5 is different), which if 'true' then will process Upserts, otherwise it will be Put.

This will allow for users that don't want Upserting to save on a HEAD Object call for every object.

trajche commented 1 year ago

Closing this until futher notice. Seems there is some issue with md5 / etag matching. Will debug more and re-open if I can reproduce.