There is a way to avoid duplicate files in mongo gridfs? Or I have to do that via application code (I am using pymongo)
To insert records in MongoDB and avoid duplicates, use “unique:true”.
GridFS places the collections in a common bucket by prefixing each with the bucket name. By default, GridFS uses two collections with a bucket named fs : fs. files.
GridFS is a driver specification for uploading and retrieving files from MongoDB. It is a specification for storing and retrieving files larger than the 16 MB limit of BSON documents.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With