谷歌app引擎python下载文件 [英] google app engine python download file

查看:107
本文介绍了谷歌app引擎python下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出一种方法,我可以创建一个制表符分隔的文件,其中包含用户定义字段的数据,并允许用户在谷歌应用程序引擎上下载该文件。



应用程序运行的沙箱环境不允许应用程序写入磁盘。还有另一种方式可以创建可下载的文件?

解决方案

当然有!例如,您可以将数据输出为 csv 。所有你需要做的是更改 Content-Type 标题。



这是这样的:

  class Test(webapp.RequestHandler):
def get(self,upload_type):
self.response.headers ['Content-Type'] ='text / csv'
self.response.out.write(','。join(['a','cool','test']))


I am trying to figure out a way where I can create a tab-delimited file containing data from user-defined fields and allow the user to download that file on google app engine.

The sandbox environment that the app runs in does not allow the application to write to disk. Is there another way where I can create a downloadable file?

解决方案

Sure there is! You can output your data as csv, for instance. All you need to do is to change the Content-Type header.

It's something like this:

class Test(webapp.RequestHandler):
    def get(self, upload_type):
        self.response.headers['Content-Type'] = 'text/csv'
        self.response.out.write(','.join(['a', 'cool', 'test']))

这篇关于谷歌app引擎python下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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