Mongo: avoid duplicate files in gridfs

gridfs, mongodb, python

Solution

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.

Problem

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

Original source