321_MediaType Media Type 是什么

321_MediaType Media Type 是什么MediaType是什么MediaType在网络协议的消息头里面叫做Content-Type使用两部分的标识符来确定一个类型所以我们用的时候其实就是为了表明我们传的东西是什么类型比如application/json:JSON格式的数据,在RFC4627中定义application/javascript:JavaScript,在RFC4329中定义但是…

大家好,又见面了,我是你们的朋友全栈君。

 

 

 

 

 

MediaType是什么

MediaType在网络协议的消息头里面叫做Content-Type
使用两部分的标识符来确定一个类型

所以我们用的时候其实就是为了表明我们传的东西是什么类型

比如

application/json:JSON格式的数据,在RFC 4627中定义
application/javascript:JavaScript,在RFC 4329中定义但是不被IE8以及之前的版本支持

audio/mp4:MP4音频
audio/mpeg:MP3 或者MPEG音频,在RFC 3003中定义

image/jpeg:JPEG 和JFIF格式,在RFC 2045 和 RFC 2046中定义
image/png:png格式,在 RFC 2083中定义

text/html:HTML格式,在RFC 2854中定义
text/javascript :JavaScript在已经废弃的RFC 4329中定义,现在推荐使用“application/javascript”。然而“text/javascript”允许在HTML 4 和5 中使用。并且与“application/javascript”不同,它是可以跨浏览器支持的。

等等
记住常用的:

文件:

text/css

text/html

text/javascript

text/plain

图片:

image/bmp

image/gif

image/jpeg

image/png

 

Json:

application/json

 

音频:

audio/mpeg

video/mpeg

audio/ogg

video/ogg

 

 

 

 

Media Type

Media Type (以前叫 MIME Type) 是一个由两部分组成的标识符,用于在网络上传入文件格式以及格式内容。The Internet Assigned Numbers Authority(IANA) 是这些分类的标准化以及发布的官方机构。Media Type 最初是在1996年11月的Request for Comments 2045 中定义的。作为MIME (Multipurpose Internet Mail Extensions) 规范的一部分,用于表示电子邮件内容和附件的类型。Media Type也被用在一些互联网协议,例如HTTP,或者文件格式,例如HTML。

 

命名Naming

Media Type 由类型和子类型组成,子类型进一步构成一个树。

当前注册的类型有:应用程序、音频、示例、字体、图像、消息、模型、多部件、文本和视频。

例如,一个HTML文件可能被指定为text/HTML;charset=utf-8

在这个例子中,html是子类型,charset是可选参数,表示字符编码。

子类型通常由媒体格式组成,但根据注册树中的不同规则,它可以或必须包含其他内容,如树前缀、生产者、产品或后缀。

类型、子类型和参数名称不区分大小写。参数值通常是大小写敏感的,但根据预期的用途,可以用大小写不敏感的方式解释。

 

常见

    application/javascript

    application/json

    application/x-www-form-urlencoded

    application/xml

    application/zip

    application/pdf

    application/sql

    application/graphql

    application/ld+json

    application/msword (.doc)

    application/vnd.openxmlformats-officedocument.wordprocessingml.document(.docx)

    application/vnd.ms-excel (.xls)

    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (.xlsx)

    application/vnd.ms-powerpoint (.ppt)

    application/vnd.openxmlformats-officedocument.presentationml.presentation (.pptx)

    application/vnd.oasis.opendocument.text (.odt)

    application/zstd (.zst)

    audio/mpeg

    audio/ogg

    multipart/form-data

    text/css

    text/html

    text/xml

    text/csv

    text/plain

    image/png

    image/jpeg

    image/gif

application/vnd.api+json

 

 

 

注册树

所有Media Type都应该使用IANA注册程序进行注册。为了提高Media Type注册过程的效率和灵活性,可以在注册树中注册不同结构的子类型,并使用树前缀来区分它们。目前创建了以下树:standard(无前缀)、vendor (vnd)。前缀),个人或vanity(prs。前缀),未注册(x.前缀)。这些注册树是在1996年11月首次定义的(已淘汰的RFC 2048 -目前的RFC 6838)。新的注册树可能由IETF标准创建,用于著名的永久性组织(如科学协会)的外部注册和管理。

 

 

标准树

标准树不使用树前缀。

type “/” subtype [“+” suffix] *[“;” parameter]

例如:application/javascript, image/png.

标准树中的注册必须与IESG直接批准的IETF规范相关联,或者由IANA认可的与标准相关的组织注册。

 

 

Vendor tree

The vendor tree includes media types associated with publicly available products. It uses the vnd. tree prefix:[1]

 

    type “/” “vnd.” subtype [“+” suffix] *[“;” parameter]

 

Examples: application/vnd.ms-excel, application/vnd.oasis.opendocument.text.

 

The terms “vendor” and “producer” are considered equivalent in the context. Industry consortia as well as non-commercial entities can register media types in the vendor tree. A registration in the vendor tree may be created by anyone who needs to interchange files associated with some software product or set of products. However, the registration belongs to the vendor or organization producing the software that employs the type being registered, and that vendor or organization can at any time elect to assert ownership of a registration done by a third party.

Personal or vanity tree

 

The personal or vanity tree includes media types associated with non publicly available products or experimental media types. It uses the prs. tree prefix:

 

    type “/” “prs.” subtype [“+” suffix] *[“;” parameter]

 

Examples: audio/prs.sid, image/prs.btif.

Unregistered tree

 

The unregistered tree includes media types intended exclusively for use in private environments and only with the active agreement of the parties exchanging them. It uses the x. tree prefix:

 

    type “/” “x.” subtype [“+” suffix] *[“;” parameter]

 

Examples: application/x.foo, video/x.bar.

 

Media types in this tree cannot be registered. According to RFC 6838 (published in January 2013), any use of types in the unregistered tree is strongly discouraged. In addition, subtypes prefixed with x- or X- are no longer considered to be members of this tree.

 

According to obsoleted RFC 2048 (published in November 1996)—it should rarely, if ever, be necessary to use unregistered types, and as such use of any x., x- or X- prefixes is discouraged. Obsoleted RFC 1590 (published in September 1993) stated that the use of the x- or X- prefix may be used for unregistered subtypes.

 

Media types that have been widely deployed (with a subtype prefixed with x- or X-) without being registered, should be, if possible, re-registered with a proper prefixed subtype. If this is not possible, the media type can, after an approval by both the media types reviewer and the IESG, be registered in the standards tree with its unprefixed subtype.

 

 

后缀Suffix

Suffix is an augmentation to the media type definition to additionally specify the underlying structure of that media type, allowing for generic processing based on that structure and independent of the exact type’s particular semantics. Media types that make use of a named structured syntax should use the appropriate IANA registered “+”suffix for that structured syntax when they are registered. Unregistered suffixes should not be used (since January 2013). Structured syntax suffix registration procedures are defined in RFC 6838.

 

The +xml suffix has been defined since January 2001 (RFC 3023), and was formally included in the initial contents of the Structured Syntax Suffix Registry along with +json, +ber, +der, +fastinfoset, +wbxml, and +zip in January 2013 (RFC 6839). Subsequent additions include +gzip, +cbor, +json-seq, and +cbor-seq.

 

 

.aac AAC audio audio/aac

.abw AbiWord document application/x-abiword

.arc Archive document (multiple files embedded) application/x-freearc

.avi AVI: Audio Video Interleave video/x-msvideo

.azw Amazon Kindle eBook format application/vnd.amazon.ebook

.bin Any kind of binary data application/octet-stream

.bmp Windows OS/2 Bitmap Graphics image/bmp

.bz BZip archive application/x-bzip

.bz2 BZip2 archive application/x-bzip2

.csh C-Shell script application/x-csh

.css Cascading Style Sheets (CSS) text/css

.csv Comma-separated values (CSV) text/csv

.doc Microsoft Word application/msword

.docx Microsoft Word (OpenXML) application/vnd.openxmlformats-officedocument.wordprocessingml.document

.eot MS Embedded OpenType fonts application/vnd.ms-fontobject

.epub Electronic publication (EPUB) application/epub+zip

.gz GZip Compressed Archive application/gzip

.gif Graphics Interchange Format (GIF) image/gif

.htm

.html HyperText Markup Language (HTML) text/html

.ico Icon format image/vnd.microsoft.icon

.ics iCalendar format text/calendar

.jar Java Archive (JAR) application/java-archive

.jpeg

.jpg JPEG images image/jpeg

.js JavaScript text/javascript

.json JSON format application/json

.jsonld JSON-LD format application/ld+json

.mid

.midi Musical Instrument Digital Interface (MIDI) audio/midi audio/x-midi

.mjs JavaScript module text/javascript

.mp3 MP3 audio audio/mpeg

.mpeg MPEG Video video/mpeg

.mpkg Apple Installer Package application/vnd.apple.installer+xml

.odp OpenDocument presentation document application/vnd.oasis.opendocument.presentation

.ods OpenDocument spreadsheet document application/vnd.oasis.opendocument.spreadsheet

.odt OpenDocument text document application/vnd.oasis.opendocument.text

.oga OGG audio audio/ogg

.ogv OGG video video/ogg

.ogx OGG application/ogg

.opus Opus audio audio/opus

.otf OpenType font font/otf

.png Portable Network Graphics image/png

.pdf Adobe Portable Document Format (PDF) application/pdf

.php Hypertext Preprocessor (Personal Home Page) application/php

.ppt Microsoft PowerPoint application/vnd.ms-powerpoint

.pptx Microsoft PowerPoint (OpenXML) application/vnd.openxmlformats-officedocument.presentationml.presentation

.rar RAR archive application/x-rar-compressed

.rtf Rich Text Format (RTF) application/rtf

.sh Bourne shell script application/x-sh

.svg Scalable Vector Graphics (SVG) image/svg+xml

.swf Small web format (SWF) or Adobe Flash document application/x-shockwave-flash

.tar Tape Archive (TAR) application/x-tar

.tif

.tiff Tagged Image File Format (TIFF) image/tiff

.ts MPEG transport stream video/mp2t

.ttf TrueType Font font/ttf

.txt Text, (generally ASCII or ISO 8859-n) text/plain

.vsd Microsoft Visio application/vnd.visio

.wav Waveform Audio Format audio/wav

.weba WEBM audio audio/webm

.webm WEBM video video/webm

.webp WEBP image image/webp

.woff Web Open Font Format (WOFF) font/woff

.woff2 Web Open Font Format (WOFF) font/woff2

.xhtml XHTML application/xhtml+xml

.xls Microsoft Excel application/vnd.ms-excel

.xlsx Microsoft Excel (OpenXML) application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

.xml XML application/xml if not readable from casual users (RFC 3023, section 3)

text/xml if readable from casual users (RFC 3023, section 3)

.xul XUL application/vnd.mozilla.xul+xml

.zip ZIP archive application/zip

.3gp 3GPP audio/video container video/3gpp

audio/3gpp if it doesn’t contain video

.3g2 3GPP2 audio/video container video/3gpp2

audio/3gpp2 if it doesn’t contain video

.7z 7-zip archive application/x-7z-compressed

 

 

 

 

 

总之,记住最常用的

文件:

text/css

text/html

text/javascript

text/plain

图片:

image/bmp

image/gif

image/jpeg

image/png

 

Json:

application/json

 

音频:

audio/mpeg

video/mpeg

audio/ogg

video/ogg

 

 

 

 

 

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/141212.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • c51单片机选择题_大学生单片机毕业设计

    c51单片机选择题_大学生单片机毕业设计?Hi,大家好,这里是丹成学长的毕设系列文章!?对毕设有任何疑问都可以问学长哦!这两年开始,各个学校对毕设的要求越来越高,难度也越来越大…毕业设计耗费时间,耗费精力,甚至有些题目即使是专业的老师或者硕士生也需要很长时间,所以一旦发现问题,一定要提前准备,避免到后面措手不及,草草了事。以下是学长亲手整理的C51单片机相关的毕业设计选题,都是经过学长精心审核的题目,适合作为毕设,难度不高,工作量达标,对毕设有任何疑问都可以问学长哦!相对容易工作量达标题目新颖,含创新点?https。…

    2022年10月3日
    3
  • UNIX基本操作命令

    UNIX基本操作命令UNIX命令基础登录系统:输入密码,密码不显示退出系统:ctrl+dexitlogout创建/修改密码:passwd密码输入后不显示,新密码要输入两次,匹配成功才算是修改密码成功UNIX命令格式:命令选项参数快捷键:ctrl+c:中断当前命令执行并返回shellctrl+d:终端传输或结束文本编辑ctrl+s:临时中断命令的屏幕输出ctrl+q:恢复由ctrl+s的临时中断ctrl+u:清除输入的整个命令行backspace:删除某个错误输入的字符常用操作命令

    2022年5月31日
    433
  • 动态链接库(DLL)初始化例程失败_无法装入solidworks DLL文件

    动态链接库(DLL)初始化例程失败_无法装入solidworks DLL文件关于solidworks中的:动态链接库(DLL)初始化例失败的解决方法

    2022年10月21日
    4
  • cv2.read 与cv2.imread的区别_vc泡腾片不能和什么一起吃

    cv2.read 与cv2.imread的区别_vc泡腾片不能和什么一起吃1、cv2.imread()接口读图像,读进来直接是BGR格式数据格式在0~255需要特别注意的是图片读出来的格式是BGR,不是我们最常见的RGB格式,颜色肯定有区别。2、cv2.cvtColor(p1,p2)是颜色空间转换函数,p1是需要转换的图片,p2是转换成何种格式。cv2.COLOR_BGR2RGB将BGR格式转换成RGB格式cv2.COLOR_BGR2GRAY将…

    2022年10月15日
    1
  • 【单调队列】数据结构之单调队列详解

    【单调队列】数据结构之单调队列详解单调队列1.初步认识单调队列是一个数据结构,并不是STL里面的内容。单调队列为何说单调,因为是队列中的元素始终保持着单增或者单减的特性。(注意始终保持这四个字)简单的sort排序就可以让一个序列有序了,为何又多此一举多出来个单调队列实现类似的功能呢?其实单调队列不只是做到了排序,还可以实现一个功能:在每次加入或者删除元素时都保持序列里的元素有序,即队首元素始终是最小值或者最大值,这个功能非常重要,单调队列我们就是使用的这个功能。举个例子:我们依次加入5个元素,分别为5,8,2,4,1那么我们假

    2022年6月25日
    20
  • windows server2016搭建ftp服务器_搭建网站的服务器

    windows server2016搭建ftp服务器_搭建网站的服务器WindowsServer2016系统中,快速搭建FTP服务器,作为文件服务器,下面分三步说明:安装IIS和FTP服务 配置FTP服务 测试FTP一、安装IIS和FTP服务首先点击开始菜单,进入找到服务器管理器,点击打开。进入后,找到管理菜单,点击添加角色和功能。进入服务器系统打开“服务器管理器”,点击“添加角色和功能”进入角色添加向导,一直点击下一步按钮到服务…

    2022年9月11日
    4

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号