Class Mimetype
- java.lang.Object
-
- software.amazon.awssdk.core.internal.util.Mimetype
-
@SdkInternalApi public final class Mimetype extends Object
Utility class that maintains a listing of known Mimetypes, and determines the mimetype of files based on file extensions.This class is obtained with the {#link
getInstance()method that recognizes loaded mime types from the filemime.typesif this file is available at the root of the classpath. The mime.types file format, and most of the content, is taken from the Apache HTTP server's mime.types file.The format for mime type setting documents is:
mimetype + extension (+ extension)*. Any blank lines in the file are ignored, as are lines starting with#which are considered comments.- See Also:
- mime.types
-
-
Field Summary
Fields Modifier and Type Field Description static StringMIMETYPE_EVENT_STREAMstatic StringMIMETYPE_GZIPThe default gzip mimetype: application/x-gzipstatic StringMIMETYPE_HTMLThe default HTML mimetype: text/htmlstatic StringMIMETYPE_OCTET_STREAMThe default binary mimetype: application/octet-streamstatic StringMIMETYPE_TEXT_PLAINstatic StringMIMETYPE_XMLThe default XML mimetype: application/xml
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MimetypegetInstance()Loads MIME type info from the file 'mime.types' in the classpath, if it's available.StringgetMimetype(File file)Determines the mimetype of a file by looking up the file's extension in an internal listing to find the corresponding mime type.StringgetMimetype(Path path)Determines the mimetype of a file by looking up the file's extension in an internal listing to find the corresponding mime type.
-
-
-
Field Detail
-
MIMETYPE_XML
public static final String MIMETYPE_XML
The default XML mimetype: application/xml- See Also:
- Constant Field Values
-
MIMETYPE_HTML
public static final String MIMETYPE_HTML
The default HTML mimetype: text/html- See Also:
- Constant Field Values
-
MIMETYPE_OCTET_STREAM
public static final String MIMETYPE_OCTET_STREAM
The default binary mimetype: application/octet-stream- See Also:
- Constant Field Values
-
MIMETYPE_GZIP
public static final String MIMETYPE_GZIP
The default gzip mimetype: application/x-gzip- See Also:
- Constant Field Values
-
MIMETYPE_TEXT_PLAIN
public static final String MIMETYPE_TEXT_PLAIN
- See Also:
- Constant Field Values
-
MIMETYPE_EVENT_STREAM
public static final String MIMETYPE_EVENT_STREAM
- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static Mimetype getInstance()
Loads MIME type info from the file 'mime.types' in the classpath, if it's available.
-
getMimetype
public String getMimetype(Path path)
Determines the mimetype of a file by looking up the file's extension in an internal listing to find the corresponding mime type. If the file has no extension, or the extension is not available in the listing contained in this class, the default mimetypeapplication/octet-streamis returned.- Parameters:
path- the file whose extension may match a known mimetype.- Returns:
- the file's mimetype based on its extension, or a default value of
application/octet-streamif a mime type value cannot be found.
-
getMimetype
public String getMimetype(File file)
Determines the mimetype of a file by looking up the file's extension in an internal listing to find the corresponding mime type. If the file has no extension, or the extension is not available in the listing contained in this class, the default mimetypeapplication/octet-streamis returned.- Parameters:
file- the file whose extension may match a known mimetype.- Returns:
- the file's mimetype based on its extension, or a default value of
application/octet-streamif a mime type value cannot be found.
-
-