How to change "Content-Type" of static resource files in WebEngine

The files below “skin/resources/“. (as said by http://doc.nuxeo.com/display/NXDOC/WebEngine+%28JAX-RS%29#WebEngine%28JAX-RS%29-Staticresources) File is found, but with bad mimetype “text/plain” instead of “video/ogg”:

    oe@charlie:~$ wget -S http://marcie:8080/nuxeo/site/portal/skin/images/demomedia/intro.ogv
--2012-08-24 12:45:01--  http://marcie:8080/nuxeo/site/portal/skin/images/demomedia/intro.ogv
Resolving marcie... 10.0.0.19
Connecting to marcie|10.0.0.19|:8080... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Set-Cookie: JSESSIONID=B85FEF72FA26C01B5A4F8DE20BA15B83.nuxeo; Path=/nuxeo
  Last-Modified: Thu, 23 Feb 2012 14:58:36 GMT
  Cache-Control: public
  Server: Nuxeo/WebEngine-1.0
  Content-Type: text/plain
  Content-Length: 1132834
  Date: Fri, 24 Aug 2012 10:45:04 GMT
  Connection: keep-alive
Length: 1132834 (1.1M) [text/plain]

I succssfully can change the mime-type for the non-WebEngine public directory (below nxserver\nuxeo.war), I guess, these files are almost untoched by nuxeo, hence the tomcat way works: in file deployment-fragment.xml add:

<extension target="web#SERVLET">
    <mime-mapping>
        <extension>ogv</extension>
        <mime-type>video/ogg</mime-type>
    </mime-mapping>

now it works for the file http://localhost:8080/nuxeo/portal/intro.ogv (notice the missing “site/“).

    oe@charlie:~$ wget -S http://marcie:8080/nuxeo/portal/intro.ogv
--2012-08-24 12:46:21--  http://marcie:8080/nuxeo/portal/intro.ogv
Resolving marcie... 10.0.0.19
Connecting to marcie|10.0.0.19|:8080... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Server: Apache-Coyote/1.1
  Accept-Ranges: bytes
  ETag: W/"1132834-1330009116000"
  Last-Modified: Thu, 23 Feb 2012 14:58:36 GMT
  Content-Type: video/ogg
  Content-Length: 1132834
  Date: Fri, 24 Aug 2012 10:46:24 GMT
  Connection: keep-alive
Length: 1132834 (1.1M) [video/ogg]

How to change it for WebEngine? I guessed an extenstion point, but the one I found http://explorer.nuxeo.org/nuxeo/site/distribution/Nuxeo%20Platform-5.6-RC3/viewComponent/org.nuxeo.ecm.platform.mimetype.service.MimetypeRegistryService/

has it already set:

<mimetype normalized="video/ogg" binary="true" iconPath="video.png">
  <mimetypes>
    <mimetype>video/ogg</mimetype>
  </mimetypes>
  <extensions>
    <extension>ogv</extension>
  </extensions>
</mimetype>
0 votes

1 answers

1824 views

ANSWER



Did you try with renaming your file to *.ogg, I think the mime type exposed will be application/ogg. I'm not a specialist but I think it may work.

Any way I think one way to add this mimetype is to add it in our nuxeo-webengine-core project this mimetype in the OSGI-INF/mimetype.properties.

I wait your feedback on the first point

1 votes



Thanks for the hint.

The mimetype seems to be registered:

oe@charlie:~$ wget -S http://marcie:8080/nuxeo/site/portal/skin/images/demomedia/intro.ogg
--2012-08-30 12:04:52--  http://marcie:8080/nuxeo/site/portal/skin/images/demomedia/intro.ogg
Resolving marcie... 10.0.0.19
Connecting to marcie|10.0.0.19|:8080... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Set-Cookie: JSESSIONID=668B414D9BBCD12B68E5826926D3405F.nuxeo; Path=/nuxeo
  Last-Modified: Thu, 23 Feb 2012 14:58:36 GMT
  Cache-Control: public
  Server: Nuxeo/WebEngine-1.0
  Content-Type: application/ogg
  Content-Length: 1132834
  Date: Thu, 30 Aug 2012 10:04:52 GMT
  Connection: keep-alive
Length: 1132834 (1.1M) [application/ogg]
Saving to: `intro.ogg&apos;

and my client is almost happy (i.e. Firefox with http://www.projekktor.com/), only a warning in the console, but the video plays!

Well, I vote for entries in mimetype.properties, as the RFC votes for it:

> Restrictions on usage: The type > application/ogg SHOULD only be used
> in situations where it is not > appropriate to serve data under the
> video/ogg or audio/ogg types. Data > served under the application/ogg
> type SHOULD use the .ogx file > extension and MUST contain an Ogg
> Skeleton logical bitstream to identify > all other contained logical
> bitstreams.

and for me it would be easier to check whether its video or audio file.

08/30/2012

Thanks for your feedback, and please use answers for answers and comment for comment. This is important for the readability of this website. Other users that will read your question will acces the real answers easily. Also mark my answer as the one that has work for you.

About your last request, I create a jira ticket to follow this issues see here:

https://jira.nuxeo.com/browse/NXP-9983

08/30/2012

I add the line on the trunk of Nuxeo, but I need to wait to add it into the first Hot Fix package as the release is in progress.

I will push it for 5.6 and 5.5 as soon as possible.

08/30/2012

If its still in progress, the same for audio would be nice and in accordance with the RFC http://tools.ietf.org/html/rfc5334#section-10.3

oga = audio/ogg

Thanks again,

08/31/2012

Ok I add it. Backport for 5.6 and 5.5 available soon.
09/03/2012