Heroku部署会自动删除服务器文件? [英] Heroku deploy deletes server files automatically?
问题描述
我是新来的 HEROKU APPS
。
在我的heroku应用程序中,我遇到了问题。这是我使用PHP脚本来保存服务器上的数据。
In my heroku app i have a problem. that is I'm using a php script to save data on server.
示例:
<?PHP
$file = "example.txt";
$data = "Something...";
file_put_contents($file,$data);
?>
此PHP脚本可以成功运行并完美保存数据。
This PHP script run successfully and save data perfectly.
但是,当我将我的APP部署到 HEROKU
以更新 - >在此过程中时, example.txt
文件自动删除。
But, when I deploy my APP to HEROKU
to update -> in this precess example.txt
file is automatically deleted.
推荐答案
Heroku文件系统
这取决于你使用的堆栈。使用Bamboo,大部分文件系统都是只读。借助Cedar,它是短暂的。
Heroku File Systems
Heroku behavior varies depending a little on the stack you use. With Bamboo, most of the file system is read-only. With Cedar, it is ephemeral.
无论哪种情况,文件系统都不会在 dynos 之间共享,并且不应该用于存储。要可靠地存储数据服务器端,您需要使用数据库(可能会将上传的数据存储为blob),或者作为另一主机或服务上的外部资产。
In either case, the file systems are not shared between dynos, and should not be used for storage. To reliably store data server-side, you will need to use the database (perhaps storing your uploads as blobs), or as external assets on another host or service.
这篇关于Heroku部署会自动删除服务器文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!