I
I
IVBAN2018-10-02 11:00:38
Django
IVBAN, 2018-10-02 11:00:38

How to pass the file name with Cyrillic to the response['Content-Disposition'] header?

In Django, I send a file via HttpResponse. I want to set the Cyrillic alphabet in the file name

response['Content-Disposition'] = 'attachment; filename="'+myfile+'”

But as I understand the Cyrillic alphabet can not be transferred

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2018-10-02
@IVBAN

RFC 8187 "Indicating Character Encoding and Language for HTTP Header Field Parameters"

from django.utils.encoding import escape_uri_path

response['Content-Disposition'] = "attachment; filename=*=UTF-8''"+ escape_uri_path(myfile)

C
chupasaurus, 2018-10-02
@chupasaurus

RFC 2047

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question