Rails Paperclip:是否有任何选项可以将上传的文件保存在公共文件夹之外? [英] Rails Paperclip : Is there any option to save the uploaded file outside of the public folder?
本文介绍了Rails Paperclip:是否有任何选项可以将上传的文件保存在公共文件夹之外?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用回形针 gem 进行上传.我想将上传的文件/图像保存在公共文件夹之外.如果您有任何想法,请分享.
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.
推荐答案
其实有很多.'public' 选项只是为了能够轻松测试.对于您的生产服务器,回形针提供了三个选项:
Actually there is many. The 'public' option is just to be able to test easily. For your production server, paperclip gives three options:
- 文件存储
- S3 存储(通过 aws-sdk)
- 储雾
- 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"
这篇关于Rails Paperclip:是否有任何选项可以将上传的文件保存在公共文件夹之外?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文