Skip to content

Commit 152b51f

Browse files
committed
improve gridfs example (properly opening file)
1 parent 66a0fca commit 152b51f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/guide/gridfs.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ In the following example, a document is created to store details about animals,
2121

2222
marmot = Animal(genus='Marmota', family='Sciuridae')
2323

24-
marmot_photo = open('marmot.jpg', 'rb')
25-
marmot.photo.put(marmot_photo, content_type = 'image/jpeg')
24+
with open('marmot.jpg', 'rb') as fd:
25+
marmot.photo.put(fd, content_type = 'image/jpeg')
2626
marmot.save()
2727

2828
Retrieval

0 commit comments

Comments
 (0)