Package play.libs
Class MimeTypes
- java.lang.Object
-
- play.libs.MimeTypes
-
public class MimeTypes extends java.lang.Object
MimeTypes utils
-
-
Constructor Summary
Constructors Constructor Description MimeTypes()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
getContentType(java.lang.String filename)
return the content-type from a file name.static java.lang.String
getContentType(java.lang.String filename, java.lang.String defaultContentType)
return the content-type from a file name.
For a text-based content-type, also return the encoding suffix eg.static java.lang.String
getMimeType(java.lang.String filename)
return the mimetype from a file namestatic java.lang.String
getMimeType(java.lang.String filename, java.lang.String defaultMimeType)
return the mimetype from a file name.static boolean
isValidMimeType(java.lang.String mimeType)
Check the mimetype is referenced in the mimetypes database
-
-
-
Method Detail
-
getMimeType
public static java.lang.String getMimeType(java.lang.String filename)
return the mimetype from a file name- Parameters:
filename
- the file name- Returns:
- the mimetype or the empty string if not found
-
getMimeType
public static java.lang.String getMimeType(java.lang.String filename, java.lang.String defaultMimeType)
return the mimetype from a file name.- Parameters:
filename
- the file namedefaultMimeType
- the default mime type to return when no matching mimetype is found- Returns:
- the mimetype
-
getContentType
public static java.lang.String getContentType(java.lang.String filename)
return the content-type from a file name. If none is found returning application/octet-stream
For a text-based content-type, also return the encoding suffix eg. "text/plain; charset=utf-8"- Parameters:
filename
- the file name- Returns:
- the content-type deduced from the file extension.
-
getContentType
public static java.lang.String getContentType(java.lang.String filename, java.lang.String defaultContentType)
return the content-type from a file name.
For a text-based content-type, also return the encoding suffix eg. "text/plain; charset=utf-8"- Parameters:
filename
- the file namedefaultContentType
- the default content-type to return when no matching content-type is found- Returns:
- the content-type deduced from the file extension.
-
isValidMimeType
public static boolean isValidMimeType(java.lang.String mimeType)
Check the mimetype is referenced in the mimetypes database- Parameters:
mimeType
- the mimeType to verify- Returns:
- true if the mimetype is referenced, false otherwise
-
-