简体   繁体   中英

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. how can i do this?

Help me to resolve this problem.

https://github.com/thoughtbot/paperclip under this got to Understanding Storage. 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

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:

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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