Sending file to the user gives UnicodeEncodeError in Flask framework
On Wed, 12 Sep 2018 06:57:36 -0700, ????? ?????? wrote:
> I want to send the user a file when he clicks the appropriate button and
> I'm suing the following.
> # Prepare selected file for download...
> send_file( '/home/nikos/wsgi/static/files/' + filename )
> But no matter what file the usser selects iam always receiving this
> [Wed Sep 12 14:10:48.450211 2018] [wsgi:error] [pid 5172] [remote
> 18.104.22.168:14089] File "/home/nikos/wsgi/downloads.py", line
> 182, in file [Wed Sep 12 14:10:48.450214 2018] [wsgi:error] [pid
> 5172] [remote 22.214.171.124:14089] send_file(
> '/home/nikos/wsgi/static/files/' + filename )
> [Wed Sep 12 14:10:48.450219 2018] [wsgi:error] [pid 5172] [remote
> 126.96.36.199:14089] File
> "/usr/lib/python3.6/site-packages/flask/helpers.py", line 592, in
> send_file [Wed Sep 12 14:10:48.450221 2018] [wsgi:error] [pid 5172]
> [remote 188.8.131.52:14089] file = open(filename, 'rb')
> [Wed Sep 12 14:10:48.450237 2018] [wsgi:error] [pid 5172] [remote
> 184.108.40.206:14089] UnicodeEncodeError: 'ascii' codec can't encode
> characters in position 30-39: ordinal not in range(128)
> How will I be able to send the selected file to the user?
try providing enough code for people to reproduce the problem & you may
get some assistance although i suspect many posters may believe you to be
a previous poster (also called Nicos) who was a disaster looking for
somewhere to happen, if that is not you then I would also suggest you try
"Free markets select for winning solutions."
-- Eric S. Raymond