如何在 Heroku 上创建永久文件?
How to create permanent files on Heroku?
我有一个带有 Postgres 数据库的电报机器人,托管在 Heroku Free dyno 上。在我的代码的一个阶段,我想永久保存腌制文件,以便以后可以访问它们。将它存储在 table 上并不是一个好主意,因为它是一个嵌套的 class,具有可变数量的输入。
问题是 Heroku 经常或至少在每次重启或推送时删除这些文件。有什么办法可以解决这个问题吗?
为此,您必须使用外部服务,例如 AWS S3、GCP 云存储(存储桶)、Azure Blob 存储等。或者您可以考虑使用 Felix Cloud Storage, Cloud Cube, Bucketeer, HDrive 等插件以便于集成。
The Heroku filesystem is ephemeral - that means that any changes to
the filesystem whilst the dyno is running only last until that dyno is
shut down or restarted. Each dyno boots with a clean copy of the
filesystem from the most recent deploy. This is similar to how many
container based systems, such as Docker, operate.
In addition, under normal operations dynos will restart every day in a
process known as "Cycling".
These two facts mean that the filesystem on Heroku is not suitable for
persistent storage of data. In cases where you need to store data we
recommend using a database addon such as Postgres (for data) or a
dedicated file storage service such as AWS S3 (for static files). If
you don't want to set up an account with AWS to create an S3 bucket we
also have addons here that handle storage and processing of static
assets https://elements.heroku.com/addons
我有一个带有 Postgres 数据库的电报机器人,托管在 Heroku Free dyno 上。在我的代码的一个阶段,我想永久保存腌制文件,以便以后可以访问它们。将它存储在 table 上并不是一个好主意,因为它是一个嵌套的 class,具有可变数量的输入。 问题是 Heroku 经常或至少在每次重启或推送时删除这些文件。有什么办法可以解决这个问题吗?
为此,您必须使用外部服务,例如 AWS S3、GCP 云存储(存储桶)、Azure Blob 存储等。或者您可以考虑使用 Felix Cloud Storage, Cloud Cube, Bucketeer, HDrive 等插件以便于集成。
The Heroku filesystem is ephemeral - that means that any changes to the filesystem whilst the dyno is running only last until that dyno is shut down or restarted. Each dyno boots with a clean copy of the filesystem from the most recent deploy. This is similar to how many container based systems, such as Docker, operate.
In addition, under normal operations dynos will restart every day in a process known as "Cycling".
These two facts mean that the filesystem on Heroku is not suitable for persistent storage of data. In cases where you need to store data we recommend using a database addon such as Postgres (for data) or a dedicated file storage service such as AWS S3 (for static files). If you don't want to set up an account with AWS to create an S3 bucket we also have addons here that handle storage and processing of static assets https://elements.heroku.com/addons