类 ConfigurableMimeFileTypeMap
- 所有已实现的接口:
InitializingBean
FileTypeMap implementation that will read
MIME type to file extension mappings from a standard JavaMail MIME type
mapping file, using a standard MimetypesFileTypeMap underneath.
The mapping file should be in the following format, as specified by the Java Activation Framework:
# map text/html to .htm and .html files text/html html htm HTML HTMLines starting with
# are treated as comments and are ignored. All
other lines are treated as mappings. Each mapping line should contain the MIME
type as the first entry and then each file extension to map to that MIME type
as subsequent entries. Each entry is separated by spaces or tabs.
By default, the mappings in the mime.types file located in the
same package as this class are used, which cover many common file extensions
(in contrast to the out-of-the-box mappings in activation.jar).
This can be overridden using the mappingLocation property.
Additional mappings can be added via the mappings bean property,
as lines that follow the mime.types file format.
- 从以下版本开始:
- 4.0
- 作者:
- Rob Harrop, Juergen Hoeller, Harry Yang
- 另请参阅:
-
setMappingLocation(cn.taketoday.core.io.Resource)setMappings(java.lang.String...)MimetypesFileTypeMap
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidCreates the final merged mapping set.protected jakarta.activation.FileTypeMapcreateFileTypeMap(cn.taketoday.core.io.Resource mappingLocation, String[] mappings) Compile aFileTypeMapfrom the mappings in the given mapping file and the given mapping entries.getContentType(File file) Delegates to the underlying FileTypeMap.getContentType(String fileName) Delegates to the underlying FileTypeMap.protected final jakarta.activation.FileTypeMapReturn the delegate FileTypeMap, compiled from the mappings in the mapping file and the entries in themappingsproperty.voidsetMappingLocation(cn.taketoday.core.io.Resource mappingLocation) Specify theResourcefrom which mappings are loaded.voidsetMappings(String... mappings) Specify additional MIME type mappings as lines that follow themime.typesfile format, as specified by the Java Activation Framework.从类继承的方法 jakarta.activation.FileTypeMap
getDefaultFileTypeMap, setDefaultFileTypeMap
-
构造器详细资料
-
ConfigurableMimeFileTypeMap
public ConfigurableMimeFileTypeMap()
-
-
方法详细资料
-
setMappingLocation
public void setMappingLocation(cn.taketoday.core.io.Resource mappingLocation) Specify theResourcefrom which mappings are loaded.Needs to follow the
mime.typesfile format, as specified by the Java Activation Framework, containing lines such as:
text/html html htm HTML HTM -
setMappings
Specify additional MIME type mappings as lines that follow themime.typesfile format, as specified by the Java Activation Framework. For example:
text/html html htm HTML HTM -
afterPropertiesSet
public void afterPropertiesSet()Creates the final merged mapping set.- 指定者:
afterPropertiesSet在接口中InitializingBean
-
getFileTypeMap
protected final jakarta.activation.FileTypeMap getFileTypeMap()Return the delegate FileTypeMap, compiled from the mappings in the mapping file and the entries in themappingsproperty. -
createFileTypeMap
protected jakarta.activation.FileTypeMap createFileTypeMap(@Nullable cn.taketoday.core.io.Resource mappingLocation, @Nullable String[] mappings) throws IOException Compile aFileTypeMapfrom the mappings in the given mapping file and the given mapping entries.The default implementation creates an Activation Framework
MimetypesFileTypeMap, passing in an InputStream from the mapping resource (if any) and registering the mapping lines programmatically.- 参数:
mappingLocation- amime.typesmapping resource (can benull)mappings- an array of MIME type mapping lines (can benull)- 返回:
- the compiled FileTypeMap
- 抛出:
IOException- if resource access failed- 另请参阅:
-
MimetypesFileTypeMap(InputStream)MimetypesFileTypeMap.addMimeTypes(String)
-
getContentType
Delegates to the underlying FileTypeMap.- 指定者:
getContentType在类中jakarta.activation.FileTypeMap- 另请参阅:
-
getContentType
Delegates to the underlying FileTypeMap.- 指定者:
getContentType在类中jakarta.activation.FileTypeMap- 另请参阅:
-