Sending file to the user gives UnicodeEncodeError in Flask framework

General support questions
Post Reply
NikosThess
Posts: 19
Joined: 2018/05/10 20:36:20

Sending file to the user gives UnicodeEncodeError in Flask framework

Post by NikosThess » 2018/09/13 11:33:22

I'm trying and trying but cannot get this working.

filepath = '/home/nikos/wsgi/static/files/' + filename
filepath = filepath.encode('utf-8')
send_file( filepath, attachment_filename=filename )

does NOT produce an error but also it does not download the file either.
I'm also tried a similar function but i alsoc ant get it working.


# Prepare selected file for download....
filepath = '/home/nikos/wsgi/static/files/'
send_from_directory( filepath, filename, as_attachment=True )

gives this message:

The browser (or proxy) sent a request that this server could not understand.

Can you help me write it properly please?

Post Reply