指定在 Magnolia 中上传的文档的内容类型

发布于 2024-12-06 10:36:40 字数 602 浏览 0 评论 0原文

我们已将 mp4 视频文件上传到 Magnolia DMS,但无法在 Safari (Mac/iPad) 上播放。调查显示,Magnolia 返回的 Content-Type 是该请求的“application/octet-stream”。直接通过 Tomcat 提供文件时,会返回正确的内容类型“video/mp4”并且视频播放正常。

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

我们知道内容类型是请求的函数(例如,如果我们将“.jpg”添加到 URL,则返回的类型为“image/jpeg”),但无法利用这些知识来提出解决方案。

更新:

我们找到了 MIME 配置,并且可以将“mp4”的 Content-Type 更改为“video/mp4”。但是,Magnolia 返回的 Content-Type 现在是

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

而为 Tomcat 托管的文件返回的正确、有效的 Content-Type 是

Content-Type:video/mp4

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

于我来说 2024-12-13 10:36:40

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

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

但是,如果您不包含该字符集,Magnolia 会自动分配默认值(在本例中为 UTF-8)。如果您想更改此行为,则需要调整源代码。

出于好奇,字符集是否给您带来了任何麻烦,或者您只是想让 Magnolia 与 Tomcat 默认情况下的行为相匹配?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文