2010-06-19 69 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();