MongoDB, Carrierwave, GridFS and prevention of files' duplication
- by Arkan
I am dealing with Mongoid, carrierwave and gridFS to store my uploads.
For example, I have a model Article, containing a file upload(a picture).
class Article
include Mongoid::Document
field :title, :type => String
field :content, :type => String
mount_uploader :asset, AssetUploader
end
But I would like to only store the file once, in the case where I'll upload many times the same file for differents articles.
I saw GridFS has a MD5 checksum.
What would be the best way to prevent duplication of identicals files ?
Thanks