How to return a file for download by Zimbra Zimlet?
I need to return some binary file in response to that request. Here is JSP code
var jspUrl = this.getResource("my.jsp");
var callback = new AjxCallback(this, this._rpcCallback, ["param1", "param2"]);
AjxRpc.invoke(null, jspUrl, null, callback, true);
I also tried "application/force-download" and "application/octet-stream" as "contentType".
<%@ page import="java.io.FileInputStream" %>
<%@ page import="java.io.BufferedInputStream" %>
<%@ page import="java.io.File" %>
<%@ page import="java.io.IOException" %>
File myfile = new File("/tmp/attachment.zip");
response.setContentLength( (int) myfile.length( ) );
FileInputStream input = new FileInputStream(myfile);
BufferedInputStream buf = new BufferedInputStream(input);
int readBytes = 0;
while((readBytes = buf.read( )) != -1)
I expect a browser to show "download file" dialog but instead of that file content is printed as text
How to fix that?