You could try file_name.decode('utf-8', 'replace') which will tell the
encoder not to throw errors but for any character it can't encode it
will replace with a ?



On Jul 31, 12:26 pm, alecs <alecs....@gmail.com> wrote:
> Environment:
>
> Request Method: GET
> Request 
> URL:http://172.16.23.33/file/4719e0bdedaa4f741f032991894d52ecb08c3476a598...
> Django Version: 1.0.3
> Python Version: 2.6.2
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'django.contrib.admin',
>  'filez.filezupload',
>  'debug_toolbar']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware')
>
> Traceback:
> File "/usr/share/python-support/python-django/django/core/handlers/
> base.py" in get_response
>   91.                 response = callback(request, *callback_args,
> **callback_kwargs)
> File "/usr/share/python-support/python-django/django/contrib/auth/
> decorators.py" in __call__
>   78.             return self.view_func(request, *args, **kwargs)
> File "/var/www/filez/filezupload/views.py" in send_file
>   253.         content_disp = u'attachment; filename="%s" ' %
> upfile.file_name
>
> Exception Type: UnicodeDecodeError at /file/
> 4719e0bdedaa4f741f032991894d52ecb08c3476a598504fd1fee92d
> Exception Value: ('ascii', '\xd0\x9d
> \xd0\xb0\xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xb9\xd0\xba\xd0\xb0
> \xd0\xbf\xd0\xbe\xd1\x87\xd1\x82\xd1\x8b.doc', 0, 1, 'ordinal not in
> range(128)')
>
> If I do upfile.file_name.decode('utf8').encode('cp1251') it works in
> IE ...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to