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

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

问题描述

我在Heroku上使用Python / Django(Cedar Stack),我有一个管理命令,我需要写这个命令将一个文件从S3存储桶中取出并处理。我不知道如何使用临时文件系统。只有某些目录是可写的吗?我发现另一篇文章暗示只有某些文件夹是可写的(但是,似乎并不适用于Cedar堆栈)。我发现这个开发文章,但没有详细说明(注意:我明白,这只是暂时的,我只需要解压缩文件并处理文件)。我可以在应用程序根目录下的任何地方创建一个文件夹吗?我怎么得到这个?这似乎我可能只是使用$ HOME。我做了一些测试,连接到

  $ heroku run bash 

正在运行:

  $ echo #HOME 

返回:

/ app



并运行:

$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ code>

会在应用程序的根目录下创建一个文件夹,并提供与其他文件和文件夹相同的用户和组。 b
$ b

那么...我在这里错过的任何东西?一个更好的方法来做到这一点?有没有一个操作系统的环境变量?我已经运行了env,但是我没有看到更好的结果。 / tmp目录,并且该请求完成后该文件将被销毁。我在Cedar做这个,我没有遇到任何问题。


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

and running:

$ echo #HOME

returns:

/app

and running:

$ 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.

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.

解决方案

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