78 Map<String, Predicate<ContentStream>> downKeys = (Map<String, Predicate<ContentStream>>) request.getSession().getAttribute(CONTENT_DOWNLOAD_KEY);
79 if(downKeys !=
null) {
80 ContentStream onDownload = (ContentStream) downKeys.get(request.getParameter(
"id"));
81 if(onDownload !=
null) {
83 String fileName = onDownload.getFileName();
86 response.setHeader(
"pragma",
"no-cache");
87 response.setHeader(
"Cache-control",
"no-cache, no-store, must-revalidate");
88 response.setHeader(
"Expires",
"01 Apr 1995 01:10:10 GMT");
90 if(contentType!=
null) {
91 response.setContentType(contentType);
94 if(fileName !=
null) {
95 fileName = fileName.substring(fileName.lastIndexOf(
'\\')+1);
96 fileName = fileName.substring(fileName.lastIndexOf(
'/')+1);
98 StringBuilder contentDisposition =
new StringBuilder();
100 contentDisposition.append(
"filename=\"");
101 contentDisposition.append(fileName);
102 contentDisposition.append(
"\"");
104 response.setHeader(
"Content-Disposition", contentDisposition.toString());
105 response.setHeader(
"Content-Lenght", onDownload.getFileSize() +
"");
108 IOUtils.copy(onDownload.getInputStream(), response.getOutputStream());
111 .entityPath(
"/file" + ElephantContext.getRelativePath(onDownload.getAbsolutePath()))
112 .entityName(fileName).comment(
"downloaded")
114 }
catch (IOException ex) {
115 Logger.getLogger(ContentDownload.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(
null), ex);
static final MimetypesFileTypeMap MIME_TYPES_FILE_MAP