def add_file(file, content_type, filename): fs = get_gridfs() res = fs.put( file, content_type=content_type, filename=filename ) return res
def get_file_by_id(_id): fs = get_gridfs() file = fs.get(ObjectId(_id)) return {"content": file.read()}
def add_file(file, content_type, filename): fs = get_gridfs() res = fs.put(file, content_type=content_type, filename=filename) return res
def get_file_by_id(_id): fs = get_gridfs() file = fs.get(ObjectId(_id)) return {"content":file.read()}