Giter Club home page Giter Club logo

Comments (7)

johnsensible avatar johnsensible commented on August 20, 2024

Hmmm. Well it appears that the trouble is that Django is trying to convert the filename to ascii.

Looks like I probably just need to url encode the file name, before setting in the the header:

http://stackoverflow.com/questions/2732268/django-unicode-filenames-with-ascii-headers

Will hopefully get round to this later - unless you fancy submitting a pull request?

from django-sendfile.

Christophe31 avatar Christophe31 commented on August 20, 2024

Ok, I'm trying it, if it works, I submit a pull request.

from django-sendfile.

Christophe31 avatar Christophe31 commented on August 20, 2024

Hoped it was that simple.

  File "/home/gunicorn/prod/ama/venv/lib/python2.6/site-packages/sendfile/__init__.py", line 59, in sendfile
    response = _sendfile(request, filename.encode('utf-8'), mimetype=mimetype)

  File "/home/gunicorn/prod/ama/venv/lib/python2.6/site-packages/sendfile/backends/nginx.py", line 7, in sendfile
    response['X-Accel-Redirect'] = _convert_file_to_url(filename)

  File "/home/gunicorn/prod/ama/venv/lib/python2.6/site-packages/sendfile/backends/_internalredirect.py", line 13, in _convert_file_to_url
    return u'/'.join(url)

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)

from django-sendfile.

Christophe31 avatar Christophe31 commented on August 20, 2024

(the worse part is that those accentuated characters used to be in extended ASCII)

from django-sendfile.

johnsensible avatar johnsensible commented on August 20, 2024

Ok do you want to give that a go? I've added some tests to check for unicode characters and encode them properly to master.

from django-sendfile.

Christophe31 avatar Christophe31 commented on August 20, 2024

It's great, I tested it in my use-case, it works.

Thanks a lot.

from django-sendfile.

johnsensible avatar johnsensible commented on August 20, 2024

Ok good. It's also on PyPI now, so should be pip installable.

from django-sendfile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.