Details
Description
The bug shows even after running the following simple code:
from pymongo import MongoClient |
import gridfs |
|
client = MongoClient('mongodb://localhost:27017/') |
db = client.my_app |
file_system = gridfs.GridFS(db) |
|
_id = file_system.put(b"hello world") |
print(_id) |
print(str(_id)) |
print(file_system.get(_id).read()) |
print(file_system.get(str(_id)).read()) |
The error I got is:
5e84dcec7ca83a32a5e09aa8
|
5e84dcec7ca83a32a5e09aa8
|
b'hello world' |
Traceback (most recent call last):
|
File "duck.py", line 12, in <module> |
print(file_system.get(str(_id)).read()) |
File "/usr/local/lib/python3.7/dist-packages/gridfs/__init__.py", line 153, in get |
gout._ensure_file()
|
File "/usr/local/lib/python3.7/dist-packages/gridfs/grid_file.py", line 490, in _ensure_file |
(self.__files, self.__file_id))
|
gridfs.errors.NoFile: no file in gridfs collection Collection(Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True), 'my_app'), 'fs.files') with _id '5e84dcec7ca83a32a5e09aa8' |