部署 求救:Paperclip 图片中文文件名出错

zuozuo · 2013年01月24日 · 最后由 zzhattzzh 回复于 2013年01月24日 · 3015 次阅读

遇到了一个很头疼的问题,我用 Paperclip 做图片上传,在本地(development 模式)调试的时候没有问题。但是部署之后只要上传中文名的图片就会出错。下面是 log

Started PUT "/users/10" for 60.247.75.71 at 2013-01-24 10:49:10 +0800
Processing by UsersController#update as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"t7L/ffapKR9/RJRap5cbMV/K0dv8IafsN+A1W1/omlU=", "user"=>{"avatar"=>#<ActionDispatch::Http::UploadedFile:0x0000000442e970 @original_filename="效果图.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"user[avatar]\"; filename=\"\xE6\x95\x88\xE6\x9E\x9C\xE5\x9B\xBE.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/tmp/RackMultipart20130124-2916-1hywkxt>>, "name"=>"ting_apple", "location_list"=>"", "industry_list"=>"", "weibo"=>"", "pitch"=>"tywertertwetwer"}, "id"=>"10"}
Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/效果图20130124-2916-e0c4mv.jpg[0]'
Command :: identify -format %m '/tmp/效果图20130124-2916-e0c4mv.jpg[0]'
Command :: identify -format %m '/tmp/效果图20130124-2916-e0c4mv.jpg[0]'
Completed 200 OK in 212ms (ActiveRecord: 0.9ms)

去各路大神来帮忙解决。

我也遇到这个问题,临时解决方案:

# lock paperclip and cocaine version
# to avoid bugs on UTF8 filenames
gem 'paperclip', '= 3.1.2'
gem 'cocaine', '= 0.3.2'

#1 楼 @qhwa 解决了,非常感谢。。。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号