简体   繁体   中英

Encoding filename for Nginx Cache

I have requests to UTF-8 urls like this :

http://www.example.com:8080/pk/s/151x120/%D8%A2%D9%88%D8%A7%D8%B2-%DA%A9.jpg

I stock the result in a file with filename :

%D8%A2%D9%88%D8%A7%D8%B2-%DA%A9.jpg

But nginx doesn't seem to see the cache and redo the same request. I have found that nginx do load this kind of UTF-8 filename :

\341\203\250\341\203.jpg

But, I don't remember either the name of the encoding or the ruby method to produce filename like this... :(

Using : Rails 3.1.3, Ruby 1.9.2, Nginx and FreeBSD

Do you just want to unescape the Percent-encoding ?

irb(main):001:0> require 'uri'
=> true
irb(main):002:0> URI.unescape "http://www.example.com:8080/pk/s/151x120/%D8%A2%D9%88%D8%A7%D8%B2-%DA%A9.jpg"
=> "http://www.example.com:8080/pk/s/151x120/\330\242\331\210\330\247\330\262-\332\251.jpg"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM