gpt4 book ai didi

ruby-on-rails - 我可以在 heroku 中托管图像吗?还是我需要S3?

转载 作者:行者123 更新时间:2023-12-03 11:33:21 26 4
gpt4 key购买 nike

我正在部署我的 Web 应用程序(用于公司客户)。因此,用户不会添加图像,而只有企业会添加。

我已经部署到 Heroku,我的图像仍在显示。我什么时候需要使用 S3?网站上总共有 100 张图片,大小会有所不同,每周超过 7 张。我可以只使用heroku吗?

最佳答案

简短的回答:如果您允许用户或管理员上传图像,则不应为此使用 Heroku 的文件系统,因为图像会突然消失。

Heroku documentation 中所述:

Each dyno gets its own ephemeral filesystem, with a fresh copy of the most recently deployed code. During the dyno’s lifetime its running processes can use the filesystem as a temporary scratchpad, but no files that are written are visible to processes in any other dyno and any files written will be discarded the moment the dyno is stopped or restarted.



这意味着用户在 Heroku 文件系统上上传的图像不仅会在每次推送时被清除,而且在每次 dyno 重启时也会被清除,这种情况偶尔会发生(即使您会频繁 ping 它们以防止它们进入休眠状态)。

一旦您开始使用第二个 web dyno,它将无法读取另一个 dyno 的文件系统,因此图像只能从一个 dyno 中可见。这会导致奇怪的问题,用户有时可以看到图像,有时看不到。

也就是说,如果您实现 a pass-through file upload to an external file store,您可以将图像临时存储在 Heroku 文件系统上。 .

关于ruby-on-rails - 我可以在 heroku 中托管图像吗?还是我需要S3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24642967/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com