http://ilnurgi1.ru/docs/python/modules_user/pymongo/bson/index.html?highlight=bson#module-bsonно в нем как-то сложно все, можно по совету коллеги
Rodegast import json
import base64
from glob import glob
pixs = glob("*.jpg")
#print(pixs)
pix= pixs[0]
with open(pix,'rb') as f:
data = base64.b64encode(f.read()).decode()
d = {'name': pix,'data': data}
with open('pix.json','w') as f:
json.dump(d,f)
между делом попробовал bson, но профита не увидел - тоже самое base64
from bson import Binary
from bson.json_util import dumps,loads
import json
from glob import glob
pixs = glob('*.jpg')
#print(pixs)
pix = pixs[0]
with open(pix,'rb') as f:
data = f.read()
d = dumps({'name':pix,'data':Binary(data)})
with open('pix.bson','w') as f:
json.dump(d,f)