The desired behavior of the application is to prompt the user for a download location while providing a default filename which works great in IE & FF but Chrome always forces it to the download directory automatically.
I'm aware that chrome has the option in Settings > Advanced > "Ask where to save each file before downloading" The downside to this option is it applies globally across all pages whereas there are other items I have tested which we want to follow the inline behavior as a result those cases are in direct conflict with each other.
I searched around but couldn't find anything definitive stating it was or was not possible in Chrome but I find it odd that a behavior that has existed for so long and has multiple RFC's attached to it is not adhered to by Chrome which is always billed as being so standards compliant. Here is how the headers are being received in the browsers as per Chrome dev tools
HTTP/1.1 200 OK
Content-Type: application/vnd.ms-powerpoint
Content-Disposition: attachment; filename="presentation.ppt"
Content-Language: en-US
Transfer-Encoding: chunked
Date: Tue, 13 Jan 2015 19:18:27 GMT
Server: WebSphere Application Server/7.0
Here is the code that sets the header server side
public void generatePowerPoint(HttpSession session, HttpServletResponse response){
String id = (String) session.getAttribute(ApplicationConstants.ID);
SlideShow ppt = reportService.generatePowerPoint(id);
try{
StringBuilder sb = new StringBuilder();
sb.append("presentation_").append(id).append(".ppt");
response.setContentType("application/vnd.ms-powerpoint");
response.setHeader("Content-Disposition", "attachment; filename=\"" + sb.toString()+ "\"");
OutputStream out = response.getOutputStream();
ppt.write(out);
out.flush();
out.close();
}
catch(IOException e) {
logger.error("The ppt could not be generated: ", e);
}
}
Anyone have any input? Is it not possible? Workaround? If you need more detail let me know.
Content-Disposition: attachment implies saving as attachment; not necessarily prompting where to save. I don't see what's wrong with Chrome's behavior.
Also, a nit: your code will generate broken header fields if the file name contains non-ASCII characters.