开发者

Specify content-type for documents uploaded in Magnolia

开发者 https://www.devze.com 2023-04-08 10:54 出处:网络
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 Magn开发者_高级运维olia is \"application/octet

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 Magn开发者_高级运维olia 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?


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消