如何使用 heroku 的临时文件系统 [英] How to use heroku's ephemeral filesystem

查看:28
本文介绍了如何使用 heroku 的临时文件系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Heroku (Cedar Stack) 上使用 Python/Django,我需要编写一个管理命令,它将从 S3 存储桶中提取文件并进行处理.我不确定我是否了解如何使用临时文件系统.是否只有某些目录可写?我发现另一篇文章暗示只有某些文件夹是可写的(但是,它似乎不适用于 Cedar 堆栈).我发现这个开发文章,但它没有详细介绍(注意:我明白这只是暂时的.我只需要解压缩文件并处理文件).我可以在应用程序根目录下的任何位置创建一个文件夹吗?我怎么会得到那个?似乎我可以只使用 $HOME.我通过连接到通过进行了一些测试

I'm using Python/Django on Heroku (Cedar Stack) and I've got a management command that I need to write that will pull a file out of an S3 bucket and process it. I'm not sure I understand how to use the ephemeral filesystem. Are there only certain directories that are writeable? I found an other article that implied that there were only certain folders that were writable (but, it doesn't seem to apply to the Cedar stack). I found this dev article but it doesn't go into much detail (note: I do understand that it's just temporary. I only need to unzip the file and process the file). Can I just create a folder anywhere under the application's root? And how would I get that? It seems like I could probably just use $HOME. I did a bit of testing by connecting to via

$ heroku run bash

并运行:

$ echo #HOME

返回:

/应用

并运行:

$ mkdir $HOME/tmp

在应用的根目录中创建一个文件夹,并提供与其他文件和文件夹相同的用户和组.

creates a folder in the app's root and gives with the same user and group as the other files and folders.

所以……我在这里遗漏了什么?有更好的方法吗?是否有用于此的操作系统环境变量?我已经运行了env",但我没有看到更好的.

So... anything I'm missing here? A better way to do it? Is there an OS environment variable for this? I've run "env" and I don't see a better one.

推荐答案

您可以在'/tmp'目录下创建一个文件,该文件将在请求完成后销毁.我正在 Cedar 上执行此操作,我没有遇到任何问题.

You can create a file under the '/tmp' directory, and that file will be destroyed after the request is complete. I'm doing this on Cedar, and I haven't had any problems.

这篇关于如何使用 heroku 的临时文件系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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