google app engine(webapp2)文件下载
2014-02-25 16:56
495 查看
enroll_file = "enroll.mobileconfig" filecontent = open('./conf/' + enroll_file, "rb").read() self.response.headers.add_header('Content-Type','application/octet-stream') self.response.headers.add_header('Content-Disposition', 'attachment; filename="' + enroll_file + '"') self.response.headers.add_header('Content-Length',str(len(filecontent))) self.response.out.write( filecontent )
在IE中测试上述代码,发现有时候下载框不能正常显示文件名,从而导致保存不了,但在firefox和safari中是正常的。
以上代码改成以下形式也可:
self.response.headers['Content-Type'] = 'application/octet-stream'
相关文章推荐
- Spring获取WebApplicationcontext,ApplicationContext几种方法详解
- 手机网站和webapp开发默认页面
- webapp系列开发之二番外篇:Dreamweaver破解
- webapp系列开发之二:Dreamweaver CS6配置Phonegap运行环境介绍
- webapp系列开发之一:在eclipse配置Phonegap框架
- Maven入门示例(2):调试helloworld webapp程序
- Maven入门示例(2):调试helloworld webapp程序
- 解决多重web应用中webapp. root重用的问题
- java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.setId
- jfinal启动正常,但是报错:oejw.WebAppContext:Failed startup
- webkit webApp 开发技术要点总结【转】
- 如何解决不同的webApp的session 共享问题
- 移动WebApp开发 JS框架对比
- UI组件库不是固化的,而是开放性的(需要根据WebApp的独特需要做个性化修改)
- iOS Webapp的桌面图标及更新
- jetty学习2-WebAppContext
- spring中的Log4jConfigListener作用和webapp.root的设置
- Eclipse 中的Maven Webapp
- com.ibm.ws.webcontainer.webapp.WebAppErrorReport.
- 轻量级的移动 webapp 框架Jingle