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

馋奶兔 提交于 2019-12-04 19:05:18

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