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

查看:162
本文介绍了部署到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已停止或重新启动.例如,这种情况在任何时候都发生 因应用程序部署而被替换,大约每天一次 作为常规测功机管理的一部分.

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天全站免登陆