Retrieving an image - Pymongo - Python - Flask

44 views Asked by At

Im trying to making an simple application that you can upload an image and retrieve it from the system. i did the upload image and its working correctly but when i retrieve the image its returning this error TypeError TypeError: argument of type 'NoneType' is not iterable. I already checked if its saving correctly on the database and as far as i know its 100% correct

This is my upload route:

def upload_image(app):
    @app.post("/")
    def upload():
        mongo = PyMongo(app)
        if 'file' in request.files:
            file = request.files['file']
            mongo.save_file(file.filename, file)
            return {"file name": file.filename}

and this is my retrieving route which is returning the above error:

def get_image(app):
   @app.get("/get_file/<filename>")
   def get_file(filename):
    mongo = PyMongo(app)
    return mongo.send_file(filename)

Does anyone knows how to fix it ? pleaseee

0

There are 0 answers