在 git push heroku 之后 - Heroku 上上传的文件丢失了 [英] After git push heroku - uploaded files on Heroku are lost

查看:31
本文介绍了在 git push heroku 之后 - Heroku 上上传的文件丢失了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的相当基本的应用程序允许用户上传头像.

My fairly basic application allows users to upload avatars.

使用

$ git add .
$ git commit -m "description"
$ git checkout master
$ git merge my-cool-new-feature
$ git push heroku

问题是,每次我向 Heroku 推送更改时,上传到 Heroku 的所有文件都会丢失.我想,问题是文件夹/文件受版本控制,所以我将该文件夹添加到 .gitignore

The problem is, every time I push changes to Heroku, all files uploaded to Heroku are lost. I thought, the problem was that the folder/files were under version control, so I added the folder to .gitignore

# Ignore User generated files
/public/system/*

并从存储库中删除文件.

and removed the files from the repository.

$ git rm -rf --cached public/system

但问题依然存在.你能指出我正确的方向吗?

But the problem persists. Can you point me in the right direction?

推荐答案

这样做的原因是 Heroku 限制了您在其服务器上存储数据的方式.回到 bamboo 堆栈时代,存储任何数据根本不可能 不使用外部服务.自从他们引入 Cedar 堆栈后,事情已经改变了一点点,但仍然无法存储持久数据.

The reason for this is because Heroku limits the way you can store data on their servers. Back in the bamboo stack days, storing any data was simply impossible without the use of an external service. Since they introduced the Cedar stack, things have changed a little bit, but storing persistent data is still not possible.

正如您所发现的,每次将新更改推送到 Heroku 应用程序时(或每次应用程序在不活动 x 分钟后关闭并重新启动),您的应用程序都会重新创建,并且所有存储的数据都将丢失.

As you've discovered, each time you push a new change to your Heroku application (or each time the application shuts down and restarts after being inactive for x minutes), your application is recreated and all stored data is lost.

最好的办法是根本不使用/public 目录,而开始使用诸如 Amazon 之类的外部服务S3Rackspace 云文件蜘蛛侠.

Your best bet is to not use the /public directory at all, and start using an external service like Amazon S3, Rackspace Cloud Files or Spideroak.

这篇关于在 git push heroku 之后 - Heroku 上上传的文件丢失了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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