public class MimeManager extends Object
Constructor and Description |
---|
MimeManager(InputStream mimeTypesInputStream) |
Modifier and Type | Method and Description |
---|---|
String |
getSanitisedMimeType(String existingMimeType,
String fileName)
If the existing mime type is listed in
GENERIC_MIME_TYPES , then return a suggested
replacement by looking up the file registered under ContainerRegistrar.MIME_TYPES_INPUTSTREAM_KEY . |
String |
getSuggestedMimeType(String fileName)
Suggests a mime type for a file name by looking up the file registered under
ContainerRegistrar.MIME_TYPES_INPUTSTREAM_KEY . |
public MimeManager(InputStream mimeTypesInputStream)
public String getSanitisedMimeType(String existingMimeType, String fileName)
GENERIC_MIME_TYPES
, then return a suggested
replacement by looking up the file registered under ContainerRegistrar.MIME_TYPES_INPUTSTREAM_KEY
.
Else return the original mime type.
Useful when uploading files, and the browser is lazy / sets the wrong content type.
existingMimeType
- The mime type that we currently know for this filefileName
- The name of the fileGENERIC_MIME_TYPES
;
otherwise, the existing mime type is returned.ContainerRegistrar.MIME_TYPES_INPUTSTREAM_KEY
public String getSuggestedMimeType(String fileName)
ContainerRegistrar.MIME_TYPES_INPUTSTREAM_KEY
.fileName
- The name of the fileContainerRegistrar.MIME_TYPES_INPUTSTREAM_KEY
Copyright © 2002-2017 Atlassian. All Rights Reserved.