[英]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.