Specify content-type for documents uploaded in Magnolia

五迷三道 提交于 2019-12-13 19:19:53

问题


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?


回答1:


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?



来源:https://stackoverflow.com/questions/7565993/specify-content-type-for-documents-uploaded-in-magnolia

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!