PDF 文件的正确 MIME 媒体类型
在处理 PDF 时,我遇到过 MIME 类型 application/pdf
和 application/x-pdf
等。
这两种类型之间有区别吗?如果有的话,区别是什么? 其中一个比另一个更受青睐吗?
我正在开发一款网络应用程序,它必须提供大量 PDF,并且我想以正确的方式(如果有的话)来完成它。
When working with PDFs, I've run across the MIME types application/pdf
and application/x-pdf
among others.
Is there a difference between these two types, and if so what is it? Is one preferred over the other?
I'm working on a web app which must deliver huge amounts of PDFs and I want to do it the correct way, if there is one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
标准媒体类型(以前称为 MIME 类型)是
application/pdf
。 该分配在 RFC 3778, The application/pdf Media Type< 中定义/a>,引用自媒体类型注册表。媒体类型由标准机构互联网号码分配机构 (IANA) 控制。 这是管理根名称服务器和 IP 地址空间的同一组织。
x-pdf
的使用早于 PDF 媒体类型的标准化。x-
命名空间中的媒体类型被视为实验性的,就像vnd.
命名空间中的媒体类型被视为供应商特定的一样。x-pdf
可能用于与旧软件兼容。The standard Media Type (formerly known as MIME types) is
application/pdf
. The assignment is defined in RFC 3778, The application/pdf Media Type, referenced from the Media Types registry.Media Types are controlled by a standards body, The Internet Assigned Numbers Authority (IANA). This is the same organization that manages the root name servers and the IP address space.
The use of
x-pdf
predates the standardization of the Media Type for PDF. Media Types in thex-
namespace are considered experimental, just as those in thevnd.
namespace are considered vendor-specific.x-pdf
might be used for compatibility with old software.这是 RFC 2045 - 多用途互联网邮件扩展 (MIME) 第一部分:互联网消息正文的格式。
类似的限制也适用于顶级类型。 来自同一源头,
(请注意,根据 RFC 2045,“媒体类型和子类型的匹配始终不区分大小写”,因此“X-”和“x-”的解释没有区别。)
因此可以合理猜测“application/x-foo”是在 IANA 定义的“application/foo”之前使用的。 不了解 IANA 令牌分配的人们仍然可能会使用它。
正如 Chris Hanson 所说,MIME 类型由 IANA 控制。 RFC 中有详细说明2048 - 多用途互联网邮件扩展 (MIME) 第四部分:注册程序。 根据 RFC 3778,引用由 IANA 作为“application/pdf”的定义,
“application/pdf”类型已经存在十多年了。 因此,在我看来,无论在新应用程序中使用“application/x-pdf”,这个决定可能都不是经过深思熟虑的。
This is a convention defined in RFC 2045 - Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies.
A similar restriction applies to the top-level type. From the same source,
(Note that per RFC 2045, "[m]atching of media type and subtype is ALWAYS case-insensitive", so there's no difference between the interpretation of 'X-' and 'x-'.)
So it's fair to guess that "application/x-foo" was used before the IANA defined "application/foo". And it still might be used by folks who aren't aware of the IANA token assignment.
As Chris Hanson said MIME types are controlled by the IANA. This is detailed in RFC 2048 - Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures. According to RFC 3778, which is cited by the IANA as the definition for "application/pdf",
The type "application/pdf" has been around for well over a decade. So it seems to me that wherever "application/x-pdf" has been used in new apps, the decision may not have been deliberate.
从维基百科媒体类型来看,
所有媒体类型均应使用 IANA 注册程序进行注册。 目前创建了以下树:
standard
、vendor
、personal
或vanity
、未注册的x.< /code>
标准:
示例:“application/xhtml+xml”、“image/png”
供应商:
个人树或虚荣树:
未注册 x。 树:
因此,很明显,标准类型 MIME 类型
application/pdf
是适合使用的类型,而您应该避免使用过时且未注册的x-
RFC 2048 和 RFC 6838。From Wikipedia Media type,
All media types should be registered using the IANA registration procedures. Currently the following trees are created:
standard
,vendor
,personal
orvanity
, unregisteredx.
Standard:
Examples: "application/xhtml+xml", "image/png"
Vendor:
Personal or Vanity tree:
Unregistered x. tree:
So its clear that the standard type MIME type
application/pdf
is the appropriate one to use while you should avoid using the obsolete and unregisteredx-
media type as stated in RFC 2048 and RFC 6838.