简体   繁体   English

Ruby on Rails PaperClip - 如何将文件存储在除S3或公共文件夹之外的其他位置

[英]Ruby on Rails PaperClip - How to store files in another location besides S3 or the public folder

I'm experimenting with PaperClip and like it and it looks to be a good solution for our project. 我正在尝试使用PaperClip并且喜欢它,它看起来是我们项目的一个很好的解决方案。 However, we'd like to store the uploaded files in another location on the server (ubuntu) besides the public folder and S3 is not an option. 但是,除了公共文件夹之外,我们还希望将上传的文件存储在服务器(ubuntu)上的其他位置,并且S3不是一个选项。 So 2 questions: 那2个问题:

1) How to set the path and url to store uploads to another directory in ubunto besides the application root or, 2) How to perhaps store the uploaded files on another LAN server as well. 1)除了应用程序根目录之外,如何设置将上传存储到ubunto中另一个目录的路径和URL,或者2)如何将上传的文件也存储在另一个LAN服务器上。

Thanks in advance to all who reply. 在此先感谢所有回复的人。 After an exhaustive search I was surprised to only see Google results for developers only using either rails_root or S3 for storage in PaperClip. 经过详尽的搜索后,我很惊讶只能看到开发人员只使用rails_root或S3在PaperClip中存储的Google搜索结果。 Also, if anyone recommends a better file uploading solution that will meet our needs than by all means please advise on that as well. 此外,如果有人建议更好的文件上传解决方案,以满足我们的需求,请务必提供相关建议。 Thanks again! 再次感谢!

You can simply pass the :path option to has_attached_file to any path you desire. 您可以简单地将:path选项has_attached_file到您想要的任何路径。 The docs talk about this, here: http://rdoc.info/gems/paperclip#Storage 文档在这里谈论这个: http//rdoc.info/gems/paperclip#Storage

If you mount some shared LAN storage on your web servers, then you can store them there. 如果您在Web服务器上mount一些共享LAN存储,那么您可以将它们存储在那里。 You do need a shared filesystem location available to all your app servers, so S3 is a common and easy to setup solution. 您确实需要一个可用于所有应用服务器的共享文件系统位置,因此S3是一种常见且易于设置的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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