Flask FileStorage object to File Object

For anyone stuck with same problem, just convert to BufferedReader

like this:

    from io import BufferedReader
    image = request.files.get('name')
    image.name = image.filename
    image = BufferedReader(image)

and then you can post it

    requests.post(urlToUnknownServer,files={'file' : image})

Maybe you can use read() without encoding it. such as this:

obj=request.files['fileName'].read()
requests.post(urlToUnknownServer,files={'file':obj})

Tags:

Python

Io

Flask