diff --git a/AUTHORS b/AUTHORS index 45a754cc3..751acb58a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -252,3 +252,4 @@ that much better: * Paulo Amaral (https://github.com/pauloAmaral) * Gaurav Dadhania (https://github.com/GVRV) * Yurii Andrieiev (https://github.com/yandrieiev) + * Tristan Brown (https://github.com/tristanbrown) diff --git a/docs/changelog.rst b/docs/changelog.rst index e82cc1246..65184fb2b 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,6 +5,7 @@ Changelog Development =========== +- Fix the `.read()` feature of FileField to properly close the file. - (Fill this out as you fix issues and develop your features). Changes in 0.18.1 diff --git a/mongoengine/fields.py b/mongoengine/fields.py index aa5aa8052..df5c1d579 100644 --- a/mongoengine/fields.py +++ b/mongoengine/fields.py @@ -1632,6 +1632,8 @@ def read(self, size=-1): return gridout.read(size) except Exception: return '' + finally: + gridout.seek(0) def delete(self): # Delete file from GridFS, FileField still remains