Create a class like the following, to override the getContentTypeFor
method of FileNameMap
and exclude the troublesome application/octet-stream
entry:
public static class MyFileNameMap implements FileNameMap
{
private FileNameMap delegate = URLConnection.getFileNameMap();
@Override
public String getContentTypeFor( String fileName )
{
String contentType = delegate.getContentTypeFor( fileName );
if( "application/octet-stream".equals( contentType ) )
{
// Sun's java classifies zip and gzip as application/octet-stream,
// which VFS then uses, instead of looking at its extension
// map for a more specific mime type
return null;
}
return contentType;
}
}
Install this new class via:
URLConnection.setFileNameMap( new MyFileNameMap() );
Now when you call FileSystemManager.resolveFile()
, VFS will choose the correct file type for gz
files by falling back to its extensions map.
Note: This is a global change to the current JVM, so be careful if you are using any other code that needs this mime type entry for things like .exe
files.