I have a web service in Flask which processes uploaded binary data:
@app.route('/v1/something', methods=['POST'])
def v1_something():
for name in request.files:
file = request.files[name]
file.read()
...
Now I'm rewriting it to AIOHTTP, but having some problem with files processing. My code:
@routes.post('/v1/something')
async def v1_something(request):
files = await request.post()
for name in files:
file = files[name]
file.read()
...
I get an error at the line await request.post()
:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 14: invalid start byte
Looks like AIOHTTP tries to read given binary as a text. How can I prevent this?