简体   繁体   中英

How to retrieve file with unicode name from Amazon S3 with fog

It works well with files with english symbols in name, but if file has cyrillic name, it fails with exception: "undefined method `body' for nil:NilClass"

@file_msg.file.retrieve_from_store!(File.basename(@file_msg.file.url))
@file_msg.file.cache_stored_file!
send_file(@file_msg.file_url,
          :disposition => 'attachment',
          :url_based_filename => false,
          :x_sendfile => true)

How i can retrieve file with non-unicode symbols in name from S3?

你应该尝试force_encodeFile.basename

@file_msg.file.retrieve_from_store! File.basename(@file_msg.file.url).force_encoding("UTF-8"))

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