Search code examples
pythonmongodbpathmongoenginefilefield

How to get filesystem path from mongoengine FileField


I need to obtain path from a FileField, in order to check it against a given file system path, to know if the file I am inserting into mongo database is already present. Is it possible?

All I get is a GridFSProxy, but I am unable to understand how to handle it.


Solution

  • You can't since it stores the data into database. If you need to store the original path then you can create an EmbeddedDocument which contains a FileField and a StringField with the path string. But remember that the stored file and the file you might find on that path are not the same