Switched to MimeTypeUtil
This commit is contained in:
parent
31db59f503
commit
2249298c93
1 changed files with 3 additions and 38 deletions
|
|
@ -25,6 +25,7 @@
|
|||
package zutil.net.http.page;
|
||||
|
||||
import zutil.Hasher;
|
||||
import zutil.MimeTypeUtil;
|
||||
import zutil.StringUtil;
|
||||
import zutil.io.IOUtil;
|
||||
import zutil.io.file.FileUtil;
|
||||
|
|
@ -145,7 +146,8 @@ public class HttpFilePage implements HttpPage{
|
|||
}
|
||||
}
|
||||
private void deliverFile(File file, HttpPrintStream out) throws IOException {
|
||||
out.setHeader("Content-Type", getMIMEType(file));
|
||||
out.setHeader("Content-Type",
|
||||
MimeTypeUtil.getMimeByExtension(FileUtil.getFileExtension(file)).toString());
|
||||
out.setHeader("Content-Length", "" + file.length());
|
||||
out.flush();
|
||||
|
||||
|
|
@ -171,43 +173,6 @@ public class HttpFilePage implements HttpPage{
|
|||
return "";
|
||||
}
|
||||
|
||||
private String getMIMEType(File file){
|
||||
switch(FileUtil.getFileExtension(file)){
|
||||
case "avi": return "video/avi";
|
||||
case "mpeg": return "video/mpeg";
|
||||
|
||||
case "mp3": return "audio/mpeg";
|
||||
case "ogg": return "audio/vorbis";
|
||||
case "wav": return "audio/wav";
|
||||
|
||||
case "bmp": return "image/bmp";
|
||||
case "gif": return "image/gif";
|
||||
case "jpg": return "image/jpeg";
|
||||
case "png": return "image/png";
|
||||
case "svg": return "image/svg+xml";
|
||||
case "tiff": return "image/tiff";
|
||||
|
||||
case "cvs": return "text/csv";
|
||||
case "htm":
|
||||
case "html": return "text/html";
|
||||
case "xml": return "text/xml";
|
||||
case "js": return "application/javascript";
|
||||
case "css": return "text/css";
|
||||
|
||||
case "bz2": return "application/x-bzip2";
|
||||
case "gz": return "application/x-gzip";
|
||||
case "tgz": return "application/x-tar";
|
||||
case "zip": return "application/zip";
|
||||
|
||||
case "exe": return "application/octet-stream";
|
||||
case "jar": return "application/java-archive";
|
||||
case "pdf": return "application/pdf";
|
||||
|
||||
default: return "text/plain";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable or disable showing of folder contents
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue