Specify content-type for documents uploaded in Magnolia
Asked Answered
L

1

1

We have uploaded an mp4 video file into our Magnolia DMS, which fails to play on Safari (Mac/iPad). Investigation shows that the Content-Type returned by Magnolia is "application/octet-stream" for the request. When serving the file through Tomcat directly, the correct Content-Type "video/mp4" is returned and video playback works.

How can we configure the content-type to be returned in Magnolia?

We know the content-type is a function of the request (e.g. if we add ".jpg" to the URL the type returned is "image/jpeg"), but couldn't use this knowledge to come up with a solution.

Update:

We found the MIME configuration and could change the Content-Type for "mp4" to "video/mp4". However, the Content-Type returned by Magnolia is now

Content-Type: video/mp4;charset=UTF-8

while the correct, working Content-Type returned for files hosted by Tomcat is

Content-Type: video/mp4

Is it possible to make Magnolia not append any charset info to the Content-Type?

Lynellelynett answered 27/9, 2011 at 8:10 Comment(0)
D
0

Glad you found the MIME configuration OK.

Both the MIME type and the character encoding are set in ContentTypeFilter.java and MIMEMapping.java. You can specify a charset for a MIME type yourself by including it in the mime-type definition. (E.g. "video/mp4;charset=UTF-8".)

If you don't include one, however, Magnolia automatically assigns the default (in this case, UTF-8). If you want to change this behavior, you'd need to tweak the source code.

Out of curiosity, is the charset causing you any trouble, or are you just trying to get Magnolia to match what Tomcat does by default?

Dodson answered 27/9, 2011 at 13:1 Comment(5)
Cheers.. We don't know if its really that charset that is causing troubles, all we know is that as soon as we upload the mp4 into Magnolia, it fails to play on Safari/Mac. The obvious difference is the MIME type, yet at this point we suspect its something else.Lynellelynett
How are you playing it? Magnolia also adds a "Content-Disposition" header that can sometimes cause issues with inlined content. You can turn that off, though: documentation.magnolia-cms.com/modules/dms.html (see "Disable Content-Disposition headers by MIME type")Dodson
We play the file via html5 video tag. We tried to turn off the "Content-Disposition" per content-type and per path but it remains at "Content-Disposition attachment; filename="video.mp4"" in the headers. After more research because of some BYTE_RANGE_ERROR_MESSAGE on the ipad, we found out that Safari/iOS "uses HTTP byte-ranges for requesting audio and video files." Now we guess that the Magnolia DMS file serving doesn't support this feature, and hence the streaming fails.Lynellelynett
Ah, right you are. Magnolia doesn't support byte-range requests currently. I've added a ticket to the Jira to get that added: jira.magnolia-cms.com/browse/MGNLDMS-215Dodson
Just checked, and issue is fixed nowLynellelynett

© 2022 - 2024 — McMap. All rights reserved.