You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bu...@apache.org on 2015/05/28 11:49:17 UTC
svn commit: r952973 - in /websites/staging/sling/trunk/content: ./
documentation/bundles/mime-type-support-commons-mime.html
Author: buildbot
Date: Thu May 28 09:49:17 2015
New Revision: 952973
Log:
Staging update by buildbot for sling
Modified:
websites/staging/sling/trunk/content/ (props changed)
websites/staging/sling/trunk/content/documentation/bundles/mime-type-support-commons-mime.html
Propchange: websites/staging/sling/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Thu May 28 09:49:17 2015
@@ -1 +1 @@
-1682056
+1682192
Modified: websites/staging/sling/trunk/content/documentation/bundles/mime-type-support-commons-mime.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/bundles/mime-type-support-commons-mime.html (original)
+++ websites/staging/sling/trunk/content/documentation/bundles/mime-type-support-commons-mime.html Thu May 28 09:49:17 2015
@@ -18,7 +18,7 @@
limitations under the License.
-->
<head>
- <title>Apache Sling - MIME Type Support (commons.mime)</title>
+ <title>Apache Sling - MIME Type Support (commons.mime and commons.contentdetection)</title>
<link rel="icon" href="/res/favicon.ico">
<link rel="stylesheet" href="/res/site.css" type="text/css" media="all">
<link rel="stylesheet" href="/res/codehilite.css" type="text/css" media="all">
@@ -89,12 +89,13 @@
- <h1>MIME Type Support (commons.mime)</h1>
+ <h1>MIME Type Support (commons.mime and commons.contentdetection)</h1>
<p>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.</p>
<div class="toc">
<ul>
<li><a href="#servlet-api-support">Servlet API Support</a></li>
-<li><a href="#enter-sling-the-mimetypeservice">Enter Sling: The MimeTypeService</a></li>
+<li><a href="#the-sling-mimetypeservice">The Sling MimeTypeService</a></li>
+<li><a href="#the-sling-contentawaremimetypeservice">The Sling ContentAwareMimeTypeService</a></li>
<li><a href="#and-more">And More...</a></li>
<li><a href="#configuring-mime-type-mappings">Configuring MIME Type Mappings</a></li>
<li><a href="#mime-type-mapping-file-format">MIME Type Mapping File Format</a></li>
@@ -107,18 +108,22 @@
<li>Mappings may be defined in the <code>mime-mapping</code> elements of the the web application descriptor <code>web.xml</code>. Managing these mappings is presumably tedious. So servlet containers may provide reasonable defaults (or not).</li>
<li>The <code>ServletContext.getMimeType(String)</code> 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 <code>mime-mapping</code> elements.</li>
</ul>
-<h2 id="enter-sling-the-mimetypeservice">Enter Sling: The MimeTypeService</h2>
-<p>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 <a href="/apidocs/sling6/org/apache/sling/commons/mime/MimeTypeService.html"><code>MimeTypeService</code></a>.</p>
+<h2 id="the-sling-mimetypeservice">The Sling MimeTypeService</h2>
+<p>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 <a href="/apidocs/sling6/org/apache/sling/commons/mime/MimeTypeService.html"><code>MimeTypeService</code></a> provided by the <code>org.apache.sling.commons.mime</code> bundle.</p>
<p>This service provides access to registered MIME types and their mappings with two methods:</p>
<ul>
<li><code>getExtension(String)</code> -- given a MIME type this methods returns a primary extension. For example for the type <code>text/plain</code> this method will return <code>txt</code></li>
<li><code>getMimeType(String)</code> -- given a file name or just the extension) returns the mapped MIME type. For example for the filename <code>sample.html</code> (or just the extension <code>html</code>) this method will return <code>text/html</code></li>
</ul>
-<p>Two more method allow to programmatically add MIME type mappings:</p>
+<p>Two more methods allow to programmatically add MIME type mappings:</p>
<ul>
<li><code>registerMimeType(InputStream)</code> registers additional mappings from the given input stream which is expected to be formated in traditional <code>mime.types</code> file format (see below).</li>
<li><code>registerMimeType(String, String...)</code> registers a single mapping for the give MIME type and the respective extensions.</li>
</ul>
+<h2 id="the-sling-contentawaremimetypeservice">The Sling ContentAwareMimeTypeService</h2>
+<p>For content-based mime type detection (as opposed to filename-based detection), the <code>org.apache.sling.commons.contentdetection</code> bundle
+provides the <code>ContentAwareMimeTypeService</code>, which takes an <code>InputStream</code> that's analyzed to detect its mime type, using Apache Tika
+by default.</p>
<h2 id="and-more">And More...</h2>
<p>Besides the <code>MimeTypeService</code> provided by Apache Sling, there is actually more:</p>
<ul>
@@ -157,7 +162,7 @@
<p>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.</p>
<p><img alt="Mime Types Web Console Plugin" src="/documentation/bundles/mimetypes.png" /></p>
<div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
- Rev. 1600942 by dklco on Fri, 6 Jun 2014 16:00:37 +0000
+ Rev. 1682192 by bdelacretaz on Thu, 28 May 2015 09:49:03 +0000
</div>
<div class="trademarkFooter">
Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project