部署到 Heroku 时如何拥有持久文件存储? [英] How do I have a persistent file storage when deploying to Heroku?

查看:15
本文介绍了部署到 Heroku 时如何拥有持久文件存储?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道每次部署时 Heroku 的 dyno 都会刷新,所以无论如何我可以让我的文件持久化,或者除了使用像 amazon S3 这样的服务之外别无他法?我使用回形针来处理文件上传,大部分文件都是 pdf 格式.

I know that Heroku's dyno gets refreshed each time a deploy is made so is there anyway I can have my files persistent or there's no other way but use services like amazon S3? I use paperclip to handle file upload and most of the files will be in pdf.

推荐答案

最好使用 S3 或其他服务.

It would be best to use S3 or another service.

每个 dyno 都有自己的临时文件系统,具有最近部署的代码的新副本.在 dyno 期间其运行的进程可以使用文件系统作为临时暂存器,但写入的文件对中的进程不可见任何其他 dyno 和任何写入的文件都将在dyno 停止或重新启动.例如,这发生在任何时候由于应用程序部署而更换,大约每天一次作为正常动态管理的一部分.

Ephemeral filesystem

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. For example, this occurs any time a dyno is replaced due to application deployment and approximately once a day as part of normal dyno management.

https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem

这篇关于部署到 Heroku 时如何拥有持久文件存储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆