[
https://issues.apache.org/jira/browse/SLING-4694?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14539275#comment-14539275
]
ASF GitHub Bot commented on SLING-4694:
---------------------------------------
GitHub user sdmcraft opened a pull request:
https://github.com/apache/sling/pull/89
SLING-4694:Add ability to identify mime type based on file content
* Initial checkin. Implements the basic idea. See
https://issues.apache.org/jira/browse/SLING-4694 for details
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/sdmcraft/sling SLING-4694
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/sling/pull/89.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #89
----
commit fefeec67c83cdd6e23b70784cf732ef692082bb4
Author: Satya Deep Maheshwari <[email protected]>
Date: 2015-05-08T07:55:09Z
SLING-4694:Add ability to identify mime type based on file content
* Initial checkin. Implements the basic idea. See
https://issues.apache.org/jira/browse/SLING-4694 for details
----
> Add ability to identify mime type based on file content
> -------------------------------------------------------
>
> Key: SLING-4694
> URL: https://issues.apache.org/jira/browse/SLING-4694
> Project: Sling
> Issue Type: Improvement
> Components: Servlets
> Affects Versions: JCR Webdav 2.2.2
> Reporter: Satya Deep Maheshwari
>
> *Problem description:* I am facing a problem with the mime type detection of
> a file. While debugging, I see that SlingTikaDetector.detect method is used
> for detecting the mime type of my file. See [1]. This method just seems to
> rely on the name of the file for detecting its mime type. Even though its
> passed an inputstream of the file, it does not seem to use it for mime type
> detection. So if my file name is something like xyz.tmp, it detects its mime
> type as application/octet-stream (the default) while it may actually be a png
> file. This is a common scenario with webdav clients wherein temporary files
> get created with such names while being edited.
> *Suggested Solution:*
> Quoting [~rombert]
> {quote}
> Following the discussions at SLING-1059 [1] and SLING-255 [2] I can
> infer that we more or less opted out of the 'heavy-weight' approach of
> actually parsing the input stream. Not sure if we want to revisit that
> TBH. At any rate, our MimeTypeService does not have an API for getting
> the file content based on the input stream.
> I think though there's a way around it, but only at the code level.
> The org.apache.sling.jcr.webdav.impl.helper.SlingResourceConfig class
> hardcodes the Detector implementation to be a SlingTikaDetector.
> I think it is worthwile to raise a Jira issue for this and it would
> definitely expedite the fix if you're willing to submit a patch / pull
> request. I think it can be as simple as adding a @Reference to a Tika
> Detector to the SlingWebDavServlet and then passing that to the
> SlingServletConfig.
> Cheers,
> Robert
> [1]: https://issues.apache.org/jira/browse/SLING-1059
> [2]: https://issues.apache.org/jira/browse/SLING-255
> {quote}
> Related mailing-list thread on this:
> http://apache-sling.73963.n3.nabble.com/mime-type-detection-td4050586.html
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)