2010-06-19 65 views

回答

0

您需要在您的项目中修改app.yaml,将application/octect-stream设置为mime_type。 检查这个例子:

- url: /download 
    static_dir: static/download 
    mime_type : application/octect-stream 

由于正确的评论指出,这是不是一个好主意来强制下载某一MIME_TYPE。 如果您的用户希望流式传输内容而不是下载内容,那么这是他们的决定,您不应该强迫他们下载文件。
你可以提供两个不同的链接,一个是流,一个是强制保存对话框。

+2

伪造mimetype强制下载通常是一个坏主意。 – 2010-06-19 17:31:06

0

如果您使用的是java,那么您可以使用以下代码。

//Set content type 
resp.setContentType("text/csv" + .getContentType()); 

//Set header for attachement 
resp.setHeader("Content-Disposition","attachment;filename=Myfile.csv"); 

//Retrieve file from database and convert to byte 
resp.getOutputStream().write(b.getFile().getBytes()); 

//Close stream 
resp.getOutputStream().close();