Closed mat-l closed 4 years ago
I noticed that in the command mentioned on top, I have used a non exisiting database called "test". While using the existing database "admin" the command:
# Save the file and get the fileid
fileid = depot.create(open('C:/Users/xxx/Documents/mongodb/mineral.jpg'))
leads to this error message:
Traceback (most recent call last):
File "C:\Users\xxx\AppData\Local\Continuum\anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3319, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-5-fe7a01f1c97a>", line 2, in <module>
fileid = depot.create(open('C:/Users/xxx/Documents/Robot_agents/mongodb/mineral.jpg'))
File "C:\Users\xxx\AppData\Local\Continuum\anaconda3\lib\site-packages\depot\io\gridfs.py", line 81, in create
last_modified=utils.timestamp())
File "C:\Users\xxx\AppData\Local\Continuum\anaconda3\lib\site-packages\gridfs\__init__.py", line 130, in put
grid_file.write(data)
File "C:\Users\xxx\AppData\Local\Continuum\anaconda3\lib\site-packages\gridfs\grid_file.py", line 386, in write
to_write = read(self.chunk_size)
File "C:\Users\xxx\AppData\Local\Continuum\anaconda3\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 247: character maps to <undefined>
You are opening the file in text mode on Python3, which leads to trying to decode it as text. Try to replace open('C:/Users/xxx/Documents/mongodb/mineral.jpg')
with open('C:/Users/xxx/Documents/mongodb/mineral.jpg', "rb")
Dear all, I am having trouble with the authentication with my MongoDB GridFS while using depot.
As mentioned in the main page (https://pypi.org/project/filedepot/) of depot I am running the following commands:
Out[2]: <depot.io.gridfs.GridFSStorage at 0x24281ead908>
which results in the output:
I am currently running MongoDB 4.2.8 Community within a Docker container on Ubuntu 18.04.
Can anybody give me a hint how to fix the authentication problem with depot? The mongodb-compass program and Python "pymongo" lib are working with the credentials: mongo_uri="mongodb://admin:admin@100.x.x.x:27017" client = MongoClient(mongo_uri)
Best regards matl