@Test public void testMimeTypes() throws Exception { Assert.assertEquals("text/plain", new FileResource(new File("myFile.txt")).getMimeType()); Assert.assertEquals("video/mp4", new FileResource(new File("myFile.mp4")).getMimeType()); Assert.assertEquals("audio/mp4", new FileResource(new File("myFile.m4a")).getMimeType()); Assert.assertEquals("application/octet-stream", new FileResource(new File("myFile.xyz")).getMimeType()); }
@Override public String getMimeType() { String fileType = getFileType(); if (fileType == null) { return "application/octet-stream"; } return MIMETYPES_BY_FILE_EXTENSION.getOrDefault(fileType, "application/octet-stream"); }
FileResource implements Resource { @Override public String getMimeType() { String fileType = getFileType(); if (fileType == null) { return "application/octet-stream"; } return MIMETYPES_BY_FILE_EXTENSION.getOrDefault(fileType, "application/octet-stream"); } }
FileResource implements Resource { @Override public String getMimeType() { String fileType = getFileType(); if (fileType == null) { return "application/octet-stream"; } return MIMETYPES_BY_FILE_EXTENSION.getOrDefault(fileType, "application/octet-stream"); } FileResource(File file);  FileResource(File file, String name); }
FileResource implements Resource { @Override public String getMimeType() { String fileType = getFileType(); if (fileType == null) { return "application/octet-stream"; } return MIMETYPES_BY_FILE_EXTENSION.getOrDefault(fileType, "application/octet-stream"); } FileResource(File file);  FileResource(File file, String name); @Override InputStream getInputStream(); @Override long getLength(); @Override Date getLastModified(); @Override String getName(); @Override String getMimeType(); File getFile(); @Override File getAsFile(); @Override String toString(); }
FileResource implements Resource { @Override public String getMimeType() { String fileType = getFileType(); if (fileType == null) { return "application/octet-stream"; } return MIMETYPES_BY_FILE_EXTENSION.getOrDefault(fileType, "application/octet-stream"); } FileResource(File file);  FileResource(File file, String name); @Override InputStream getInputStream(); @Override long getLength(); @Override Date getLastModified(); @Override String getName(); @Override String getMimeType(); File getFile(); @Override File getAsFile(); @Override String toString();  }