tapioco123
tapioco123

Reputation: 3525

Mongo: avoid duplicate files in gridfs

There is a way to avoid duplicate files in mongo gridfs? Or I have to do that via application code (I am using pymongo)

Upvotes: 5

Views: 2984

Answers (2)

Derick
Derick

Reputation: 36784

The MD5 sum is already part of Mongo's gridfs meta-data, so you could simply set a unique index on that column and the server will refuse to store the file. No need to compare on the client side.

Upvotes: 5

Denis
Denis

Reputation: 7343

You could use md5 hash and compare new hash with exists before saving file.

Upvotes: 1

Related Questions