[英]Paperclip - files outside of the application folder
我的回形针配置是:
has_mongoid_attached_file :avatar,
:path => "/nas/avatars/:id/:style/:id.:extension",
:url => "/system/:id/:style/:id.:extension",
:styles => { :profile => "100x100", :thumb => "64x64" }
我尝试通过以下方式显示它:
image_tag @profile.avatar.url(:profile)
但它返回/system/54995fec7061762375100000/profile/54995fec7061762375100000.jpg 404找不到
是否可以将文件物理保存在应用程序文件夹(已安装NAS)之外?
是的,但是您需要以某种方式提供此文件,因为它们不在public
目录中。 一种方法(我使用的方法)是为此创建一个单独的控制器。 就像是:
def show
send_file @profile.avatar.path(:profile), type: 'image/jpeg', disposition: 'inline'
end
您也可以尝试使用符号链接,但我不知道它如何工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.