简体   繁体   English

回形针将图像保存在:rails_root之外

[英]Paperclip saving the image outside the :rails_root

Hi am using paperclip for image upload, problem is i want to access the image for two application deployed in the same server, for that i have to save the image in common folder outside of rails root. 嗨,我正在使用回形针进行图像上传,问题是我想访问部署在同一服务器上的两个应用程序的图像,因为我必须将图像保存在rails根之外的公共文件夹中。 how can i do this? 我怎样才能做到这一点?

Help me to resolve this problem. 帮我解决这个问题。

https://github.com/thoughtbot/paperclip under this got to Understanding Storage. https://github.com/thoughtbot/paperclip在此下进入了了解存储。 You can specify path to whatever folder you want. 您可以指定所需文件夹的路径。

You can change it by two ways: 您可以通过两种方式更改它:

1) config/application.rb or in any of the config/environments/*.rb files 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 initializer: 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM