ContentTypes

interface ContentTypes

提供了一系列预定义的、标准的 ContentType 实例以及用于创建自定义内容类型的工厂方法。

使用此接口可以以类型安全的方式引用常见的 MIME 类型,避免在代码中使用 "魔术字符串"(hardcoded strings), 从而减少拼写错误并利用 IDE 的自动补全功能。

Author

M8Test, [email protected], https://m8test.com

Functions

Link copied to clipboard
abstract fun create(contentType: String, contentSubtype: String): ContentType

通过指定主类型和子类型来创建一个 ContentType 对象。

Link copied to clipboard
abstract fun getAny(): ContentType

代表任意内容类型 * / *

Link copied to clipboard

代表任意 application 类型 application / *

Link copied to clipboard

代表 application/atom+xml

Link copied to clipboard

代表 application/cbor

Link copied to clipboard

代表 application/vnd.openxmlformats-officedocument.wordprocessingml.document (Word)。

Link copied to clipboard

代表 application/x-www-form-urlencoded,用于网页表单提交。

Link copied to clipboard

代表 application/gzip

Link copied to clipboard

代表 application/hal+json

Link copied to clipboard

代表 application/javascript

Link copied to clipboard

代表 application/json

Link copied to clipboard

代表 application/octet-stream,用于通用的二进制数据。

Link copied to clipboard

代表 application/pdf

Link copied to clipboard

代表 application/vnd.openxmlformats-officedocument.presentationml.presentation (PowerPoint)。

Link copied to clipboard

代表 application/problem+json

Link copied to clipboard

代表 application/problem+xml

Link copied to clipboard

代表 application/protobuf (Protocol Buffers)。

Link copied to clipboard

代表 application/rss+xml

Link copied to clipboard

代表 application/soap+xml

Link copied to clipboard

代表 application/wasm (WebAssembly)。

Link copied to clipboard

代表 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (Excel)。

Link copied to clipboard

代表 application/xml

Link copied to clipboard

代表 application/xml-dtd

Link copied to clipboard

代表 application/yaml

Link copied to clipboard

代表 application/zip

Link copied to clipboard
abstract fun getAudioAny(): ContentType

代表任意 audio 类型 audio / *

Link copied to clipboard
abstract fun getAudioMP4(): ContentType

代表 audio/mp4

Link copied to clipboard
abstract fun getAudioMPEG(): ContentType

代表 audio/mpeg (MP3)。

Link copied to clipboard
abstract fun getAudioOGG(): ContentType

代表 audio/ogg

Link copied to clipboard
abstract fun getFontAny(): ContentType

代表任意 font 类型 font / *

Link copied to clipboard

代表 font/collection

Link copied to clipboard
abstract fun getFontOtf(): ContentType

代表 font/otf

Link copied to clipboard
abstract fun getFontSfnt(): ContentType

代表 font/sfnt

Link copied to clipboard
abstract fun getFontTtf(): ContentType

代表 font/ttf

Link copied to clipboard
abstract fun getFontWoff(): ContentType

代表 font/woff

Link copied to clipboard
abstract fun getFontWoff2(): ContentType

代表 font/woff2

Link copied to clipboard
abstract fun getImageAny(): ContentType

代表任意 image 类型 image / *

Link copied to clipboard
abstract fun getImageAPNG(): ContentType

代表 image/apng (Animated PNG)。

Link copied to clipboard
abstract fun getImageAVIF(): ContentType

代表 image/avif

Link copied to clipboard
abstract fun getImageBMP(): ContentType

代表 image/bmp

Link copied to clipboard
abstract fun getImageGIF(): ContentType

代表 image/gif

Link copied to clipboard
abstract fun getImageHEIC(): ContentType

代表 image/heic

Link copied to clipboard
abstract fun getImageHEIF(): ContentType

代表 image/heif

Link copied to clipboard
abstract fun getImageJPEG(): ContentType

代表 image/jpeg

Link copied to clipboard
abstract fun getImageJXL(): ContentType

代表 image/jxl

Link copied to clipboard
abstract fun getImagePNG(): ContentType

代表 image/png

Link copied to clipboard
abstract fun getImageSVG(): ContentType

代表 image/svg+xml

Link copied to clipboard
abstract fun getImageTIFF(): ContentType

代表 image/tiff

Link copied to clipboard
abstract fun getImageWEBP(): ContentType

代表 image/webp

Link copied to clipboard
abstract fun getImageXIcon(): ContentType

代表 image/x-icon (Favicon)。

Link copied to clipboard
abstract fun getMessageAny(): ContentType

代表任意 message 类型 message / *

Link copied to clipboard
abstract fun getMessageHttp(): ContentType

代表 message/http

Link copied to clipboard

代表 multipart/alternative

Link copied to clipboard

代表任意 multipart 类型 multipart / *

Link copied to clipboard

代表 multipart/byteranges

Link copied to clipboard

代表 multipart/encrypted

Link copied to clipboard

代表 multipart/form-data,用于文件上传和表单。

Link copied to clipboard

代表 multipart/mixed

Link copied to clipboard

代表 multipart/related

Link copied to clipboard

代表 multipart/signed

Link copied to clipboard
abstract fun getTextAny(): ContentType

代表任意 text 类型 text / *

Link copied to clipboard
abstract fun getTextCSS(): ContentType

代表 text/css

Link copied to clipboard
abstract fun getTextCSV(): ContentType

代表 text/csv

Link copied to clipboard

代表 text/event-stream (Server-Sent Events)。

Link copied to clipboard
abstract fun getTextHtml(): ContentType

代表 text/html

Link copied to clipboard

代表 text/javascript

Link copied to clipboard
abstract fun getTextPlain(): ContentType

代表 text/plain

Link copied to clipboard
abstract fun getTextVCard(): ContentType

代表 text/vcard

Link copied to clipboard
abstract fun getTextXml(): ContentType

代表 text/xml

Link copied to clipboard
abstract fun getVideoAny(): ContentType

代表任意 video 类型 video / *

Link copied to clipboard
abstract fun getVideoMP4(): ContentType

代表 video/mp4

Link copied to clipboard
abstract fun getVideoMPEG(): ContentType

代表 video/mpeg

Link copied to clipboard
abstract fun getVideoOGG(): ContentType

代表 video/ogg

Link copied to clipboard

代表 video/quicktime

Link copied to clipboard
abstract fun parse(value: String): ContentType

从一个包含完整内容类型值的字符串中解析出 ContentType 对象。