enable better content type definition for the download file service
authorBruno Sinou <bsinou@argeo.org>
Tue, 9 Jun 2015 05:50:37 +0000 (05:50 +0000)
committerBruno Sinou <bsinou@argeo.org>
Tue, 9 Jun 2015 05:50:37 +0000 (05:50 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@8171 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.eclipse.ui.rap/src/org/argeo/eclipse/ui/specific/OpenFileService.java

index 926c8aaaccc72bfc369150925abe0fd812024e74..a9302e1948d50765cb8d259b1fedfb78d2b06556 100644 (file)
@@ -49,10 +49,10 @@ public class OpenFileService implements ServiceHandler {
                String uri = request.getParameter(PARAM_FILE_URI);
 
                // Set the Metadata
-               response.setContentType("application/octet-stream");
                response.setContentLength((int) getFileLength(uri));
                if (fileName == null || "".equals(fileName.trim()))
                        fileName = getFileName(uri);
+               response.setContentType(getMimeTypeFromName(fileName));
                String contentDisposition = "attachment; filename=\"" + fileName + "\"";
                response.setHeader("Content-Disposition", contentDisposition);
 
@@ -104,4 +104,9 @@ public class OpenFileService implements ServiceHandler {
        private String getFilePathFromUri(String uri) {
                return uri.substring((FILE_SCHEME + SCHEME_HOST_SEPARATOR).length());
        }
+
+       /** Overwrite to precise the content type */
+       protected String getMimeTypeFromName(String fileName) {
+               return "application/octet-stream";
+       }
 }
\ No newline at end of file