I use the following code to send a file in rails:
send_file(file_to_send,
:x_sendfile => true,
:filename => file_name,
:type => file_mime_type,
:disposition => disposition,
:stream => true,
:buffer_size => 4096)
where file_name
contains a utf-8 filename like lörem ipsüm.docx
.
In Firefox, Chrome it works fine. In Internet Explorer and even Edge the special German chars (and probably all non default chars) are broken.
The filename on download is Lörem ipsüm.docx
.
After many other things I tried :filename => URI.encode(file_name)
which leads to a correct filename in IE and Edge, BUT not in Chrome and FF. There I do get the encoded filename Lo%CC%88rem%20ipsu%CC%88m.docx
.
So anyone has a clue how I can fix this that it works on all browsers?