回形针 - 应用程序文件夹外的文件
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)
但是 returns /system/54995fec7061762375100000/profile/54995fec7061762375100000.jpg 404 未找到
是否可以将文件物理保存到应用程序文件夹(挂载的 NAS)之外?
是的,但是您需要以某种方式提供这些文件,因为它们不在 public
目录中。一种方法(我使用的)是为此创建一个单独的控制器。类似于:
def show
send_file @profile.avatar.path(:profile), type: 'image/jpeg', disposition: 'inline'
end
您也可以尝试使用符号链接,但我不知道它是如何工作的。
我的回形针配置是:
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)
但是 returns /system/54995fec7061762375100000/profile/54995fec7061762375100000.jpg 404 未找到
是否可以将文件物理保存到应用程序文件夹(挂载的 NAS)之外?
是的,但是您需要以某种方式提供这些文件,因为它们不在 public
目录中。一种方法(我使用的)是为此创建一个单独的控制器。类似于:
def show
send_file @profile.avatar.path(:profile), type: 'image/jpeg', disposition: 'inline'
end
您也可以尝试使用符号链接,但我不知道它是如何工作的。