From 152b51fd339a1bb9db254555461b5e6651bc3a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastien=20G=C3=A9rard?= Date: Sun, 29 Dec 2019 14:36:50 +0100 Subject: [PATCH] improve gridfs example (properly opening file) --- docs/guide/gridfs.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide/gridfs.rst b/docs/guide/gridfs.rst index 6e4a75a5..0baf88e0 100644 --- a/docs/guide/gridfs.rst +++ b/docs/guide/gridfs.rst @@ -21,8 +21,8 @@ In the following example, a document is created to store details about animals, marmot = Animal(genus='Marmota', family='Sciuridae') - marmot_photo = open('marmot.jpg', 'rb') - marmot.photo.put(marmot_photo, content_type = 'image/jpeg') + with open('marmot.jpg', 'rb') as fd: + marmot.photo.put(fd, content_type = 'image/jpeg') marmot.save() Retrieval