Rails Paperclip : Is there any option to save the uploaded file outside of the public folder?

99封情书 提交于 2019-12-09 23:25:32

问题


I am using paperclip gem for uploading. And i want to save the uploaded file/image outside of the public folder. If you have any idea please share.


回答1:


Actually there is many. The 'public' option is just to be able to test easily. For your production server, paperclip gives three options:

  • File Storage
  • S3 Storage (via aws-sdk)
  • Fog Storage

File storage can be configured to go to any folder you want with something like:

config.paperclip_defaults = {    
  :path => "/yourfolder/:basename.:extension"
}

This can be overridden on the class itself if needed:

has_attached_file :avatar, 
  :path => "/yourotherfolder/:basename.:extension"


来源:https://stackoverflow.com/questions/23950986/rails-paperclip-is-there-any-option-to-save-the-uploaded-file-outside-of-the-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!