Reputation: 842
I can't seem to find a 'checksum' property on a CollectionFS object. I'd like to have it to prevent duplicate files from being uploaded.
Is there any best-practice approach to prevent duplicates?
Should I do it myself client side and append to the CollectionFS object? I didn't want to create another mongo collection to track the files.
Upvotes: 0
Views: 166
Reputation: 20226
Best practice is normally to hash the file contents (excluding the metadata) with for example, md5, and then store the hash key with the collectionFS object itself (Once you have a document _id you can update that document with a new key). Index on the hash for quick comparison against prior documents.
Upvotes: 1