[英]Paperclip saving the image outside the :rails_root
嗨,我正在使用回形针进行图像上传,问题是我想访问部署在同一服务器上的两个应用程序的图像,因为我必须将图像保存在rails根之外的公共文件夹中。 我怎样才能做到这一点?
帮我解决这个问题。
https://github.com/thoughtbot/paperclip在此下进入了了解存储。 您可以指定所需文件夹的路径。
您可以通过两种方式更改它:
1)config / application.rb或任何config / environments / *。rb文件中
module YourApp
class Application < Rails::Application
# Other code...
config.paperclip_defaults = {:storage => :fog, :fog_credentials => {:provider => "Local", :local_root => "#{Rails.root}/public"}, :fog_directory => "", :fog_host => "localhost"}
end
end
2)Rails初始化器:
Paperclip::Attachment.default_options[:storage] = :fog
Paperclip::Attachment.default_options[:fog_credentials] = {:provider => "Local", :local_root => "#{Rails.root}/public"}
Paperclip::Attachment.default_options[:fog_directory] = ""
Paperclip::Attachment.default_options[:fog_host] = "http://localhost:3000"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.