The mediaContent item type has a mediaType
property that indicates the type of binary file the item’s url
property points to. The mediaType
property is an enumerated property that accepts the following values:
Video
Image
PDF
Audio
Other
The mediaType
property is set automatically by the /atg/content/service/MimeCategoryTyper
component, which is of class atg.servlet.MimeCategoryTyper
. This component uses the /atg/dynamo/servlet/pipeline/MimeTyper
component to examine the filename extension of the mediaContent item’s url
property and determine the corresponding MIME type. For example, if the extension is mpeg
, MimeTyper
returns video/mpeg
as the MIME type.
MimeCategoryTyper
then examines the MIME type returned by MimeTyper
and returns one of the MIME categories listed above. For example, if the MIME type is image/jpeg
or image/gif
(or any other image type), MimeCategoryTyper
returns Image.
MimeCategoryTyper
has properties for specifying strings that it attempts to match with the MIME type to determine the MIME category:
exactMatchCategories
startsWithCategories
endsWithCategories
Each of these properties is a Map in which the keys are strings used for comparison with MIME types, and the values are MIME categories. To return the appropriate MIME category, MimeCategoryTyper
uses the following logic:
MimeCategoryTyper
compares the MIME type with theexactMatchCategories
keys. If there is an exact match between a key and the MIME type, the Map value for that key is returned as the MIME category.If there is no exact match,
MimeCategoryTyper
compares the MIME type with thestartsWithCategories
keys. If there is a match between a key and the beginning of the MIME type string, the Map value for that key is returned as the MIME category.If there is no match,
MimeCategoryTyper
compares the MIME type with theendsWithCategories
keys. If there is a match between a key and the ending of the MIME type string, the Map value for that key is returned as the MIME category.If there is no match,
MimeCategoryTyper
returns the value of itsdefaultCategory
property as the MIME category.
The MimeCategoryTyper
component’s properties file includes the following:
mimeTyper=/atg/dynamo/servlet/pipeline/MimeTyper
startsWithCategories=\
image=Image, \
video=Video, \
audio=Audio
endsWithCategories=\
pdf=PDF
defaultCategory=Other
So, for example, if the MIME type is video/mpeg
, the MIME category is Video; if the MIME type is application/pdf
, the MIME category is PDF; and if the MIME type is application/rtf
, the MIME category is Other.