You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2015/05/28 11:49:04 UTC

svn commit: r1682192 - /sling/site/trunk/content/documentation/bundles/mime-type-support-commons-mime.mdtext

Author: bdelacretaz
Date: Thu May 28 09:49:03 2015
New Revision: 1682192

URL: http://svn.apache.org/r1682192
Log:
SLING-4694 - mention the new commons.contentdetection bundle

Modified:
    sling/site/trunk/content/documentation/bundles/mime-type-support-commons-mime.mdtext

Modified: sling/site/trunk/content/documentation/bundles/mime-type-support-commons-mime.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/bundles/mime-type-support-commons-mime.mdtext?rev=1682192&r1=1682191&r2=1682192&view=diff
==============================================================================
--- sling/site/trunk/content/documentation/bundles/mime-type-support-commons-mime.mdtext (original)
+++ sling/site/trunk/content/documentation/bundles/mime-type-support-commons-mime.mdtext Thu May 28 09:49:03 2015
@@ -1,4 +1,4 @@
-Title: MIME Type Support (commons.mime)
+Title: MIME Type Support (commons.mime and commons.contentdetection)
 
 Support for MIME type mappings is generally a problematic issue. On the one hand applications have to take care to stay up to date with their mappings on the other hands in web applications it is tedious to maintain the mappings. Apache Sling takes a very user and deployment friendly approadch to this problem which is described in detail on this page.
 
@@ -12,9 +12,9 @@ The Servlet API specification provides a
 * The `ServletContext.getMimeType(String)` returns a MIME type for a given file name based on the extension of the filename. The mapping returned is based on the servlet container configuration as well as the web application descriptor's `mime-mapping` elements.
 
 
-## Enter Sling: The MimeTypeService
+## The Sling MimeTypeService
 
-Already at the start of the Sling project we realized, that just basing the MIME type mapping decisions on the servlet container will not yield acceptable results. For this reason the Apache Sling projects provides a spezialized and configurable service supporting such mappings: The [`MimeTypeService`](/apidocs/sling6/org/apache/sling/commons/mime/MimeTypeService.html).
+Already at the start of the Sling project we realized, that just basing the MIME type mapping decisions on the servlet container will not yield acceptable results. For this reason the Apache Sling projects provides a spezialized and configurable service supporting such mappings: The [`MimeTypeService`](/apidocs/sling6/org/apache/sling/commons/mime/MimeTypeService.html) provided by the `org.apache.sling.commons.mime` bundle.
 
 This service provides access to registered MIME types and their mappings with two methods:
 
@@ -22,12 +22,16 @@ This service provides access to register
 * `getMimeType(String)` -- given a file name or just the extension) returns the mapped MIME type. For example for the filename `sample.html` (or just the extension `html`) this method will return `text/html`
 
 
-Two more method allow to programmatically add MIME type mappings:
+Two more methods allow to programmatically add MIME type mappings:
 
 * `registerMimeType(InputStream)` registers additional mappings from the given input stream which is expected to be formated in traditional `mime.types` file format (see below).
 * `registerMimeType(String, String...)` registers a single mapping for the give MIME type and the respective extensions.
 
+## The Sling ContentAwareMimeTypeService
 
+For content-based mime type detection (as opposed to filename-based detection), the `org.apache.sling.commons.contentdetection` bundle 
+provides the `ContentAwareMimeTypeService`, which takes an `InputStream` that's analyzed to detect its mime type, using Apache Tika
+by default.
 
 ## And More...
 
@@ -37,11 +41,8 @@ Besides the `MimeTypeService` provided b
 * Each Servlet (and JSP scripts) is initialized by Apache Sling with a `ServletContext` instance whose implementation of the `getMimeType(String)` effectively calls the `MimeTypeService.getMimeType(String)` method.
 * The Scripting support infrastructure of Sling sets the response content type on behalf of the script to the default value as returned by the `SlingHttpServletRequest.getResponseContentType()` method. At the same time the response character set is also set to `UTF-8` for *text* content types.
 
-
-
 ## Configuring MIME Type Mappings
 
-
 The implementation of the `MimeTypeService` in the Apache Sling MIME type mapping support (`org.apache.sling.commons.mime`) bundle supports a numnber of ways to configure and extend the set of MIME type mappings:
 
 * Default configuration. The default configuration is based on the [`mime.types`](http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types) file maintained by Roy Fielding for the Apache httpd project and some extensions by Apache Sling.
@@ -59,7 +60,6 @@ Please note, that existing mappings cann
 1. Mappings registered calling the `MimeTypeService.registerMimeType` method
 1. Mappings provided by `MimeTypeProvider` services
 
-
 ## MIME Type Mapping File Format
 
 The file format for MIME type mapping files is rather simple:
@@ -71,9 +71,8 @@ The file format for MIME type mapping fi
 
 THe data line format described here also applies to configuration provided by the values of the `mime.types` property of the MIME type service configuration. The file format description applies to all `META-INF/mime.types` files provided by the bundles as well as input streams supplied to the `MimeTypeService.registerMimeType(InputStream)` method.
 
-
 ## Web Console Plugin
 
 The Apache Sling MIME type mapping support bundle implements a plugin for the Apache Felix Web Console which may be consulted to investigate the current contents of the MIME type mapping tables.
 
-![Mime Types Web Console Plugin](/documentation/bundles/mimetypes.png)
\ No newline at end of file
+![Mime Types Web Console Plugin](/documentation/bundles/mimetypes.png)