指定在Magnolia中上传的文档的内容类型 [英] Specify content-type for documents uploaded in Magnolia

查看:84
本文介绍了指定在Magnolia中上传的文档的内容类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已将mp4视频文件上传到我们的Magnolia DMS,该文件无法在Safari(Mac/iPad)上播放.调查显示,对于请求,木兰返回的Content-Type是"application/octet-stream".直接通过Tomcat提供文件时,将返回正确的Content-Type"video/mp4",并且可以播放视频.

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.

我们如何配置要在Magnolia中返回的内容类型?

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

我们知道content-type是请求的函数(例如,如果我们在U​​RL中添加".jpg",则返回的类型是"image/jpeg"),但是无法使用此知识来提出解决方案.

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.

更新:

我们找到了MIME配置,可以将"mp4"的内容类型更改为"video/mp4".但是,木兰返回的Content-Type现在是

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

内容类型:视频/mp4;字符集= UTF-8

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

对于Tomcat托管的文件返回的正确的正常Content-Type是

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

内容类型:视频/mp4

Content-Type: video/mp4

是否可以使木兰不向内容类型附加任何字符集信息?

推荐答案

很高兴您发现MIME配置正常.

Glad you found the MIME configuration OK.

MIME类型和字符编码均在 ContentTypeFilter.java MIMEMapping.java 中设置.您可以通过将其包含在mime-type定义中来自己指定MIME类型的字符集. (例如"video/mp4; charset = UTF-8".)

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".)

但是,如果您不包括其中一个,则Magnolia会自动分配默认值(在这种情况下为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.

出于好奇,是因为字符集给您带来了麻烦,还是您只是想让Magnolia与Tomcat的默认设置相匹配?

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?

这篇关于指定在Magnolia中上传的文档的内容类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆