通过 send_data (rails、回形针)传输数据的替代方案?

发布于 2024-10-19 18:36:50 字数 451 浏览 12 评论 0原文

我为具有各个域的用户提供将不同文件上传到我的网站的能力。所有数据都存储在公共文件夹之外的服务器上的一个目录中。由于权限和架构原因,我无法将其存储在公共文件夹中!

我有一个控制器,可以通过 send_data 处理不同域的所有文件(例如权限),不幸的是,速度非常慢:(。我可以使用更快的替代方案吗?

这是我的架构:

一个项目

domain1.com/assets -> 指向文件控制器 = 给出来自以下位置的数据:/var/assets/domain1/ otherprojectdomain1.com/assets ->指向文件控制器=给出来自以下位置的数据:/var/assets/domain1/

其他项目

domain2.com/assets ->指向文件控制器 = 给出来自以下位置的数据:/var/assets/domain2/

I give my users, with individual domains the ability to upload different files to my site. All data is stored out of the public folder in one directory on the server. Because of permission and architecture reasons, I cannot store it in the public folder!

I have one controller that handles all files (permissions eg.) for different domains via send_data, which is unfortunately very slow :(. Are there any faster alternatives I can use?

Here is my architecture:

One Project

domain1.com/assets -> points to files controller = gives the data from: /var/assets/domain1/
otherprojectdomain1.com/assets -> points to files controller = gives the data from: /var/assets/domain1/

Other Project

domain2.com/assets -> points to files controller = gives the data from: /var/assets/domain2/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

阳光的暖冬 2024-10-26 18:36:50

如果您尝试从服务器提供实际文件,您可能最好使用 send_file 而不是发送数据。您还可以使用 send_file 选项调整 apache 或 nginx 设置。

这是一个链接,显示了使用 send_file 的控制器的示例:
保护your-paperclip-downloads

希望这会有所帮助。

If you are trying to serve actual files from a server your probably better off using send_file rather than send_data. You can also tweak apache or nginx settings with the send_file option.

here is a link which shows an example of a controller using send_file:
protecting-your-paperclip-downloads

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文