Skip to content

MIMEType

Josh Wright edited this page Jan 14, 2021 · 4 revisions

MIMEType

An HTTP Media Type. It has a value:​ String appropriate for putting into Content-Type headers.

public struct MIMEType

Initializers

init(_:)

Create with a string.

public init(_ value: String)

Parameters

  • value: The string of the MIME type.

init?(fileExtension:)

Creates based off of a known file extension that can be mapped to an appropriate Content-Type header value. Returns nil if no MIME type is known.

public init?(fileExtension: String)

The . in front of the file extension is optional.

Usage:

let mt = MediaType(fileExtension: "html")!
print(mt.value) // "text/html"

Parameters

  • fileExtension: The file extension to look up a MIME type for.

Properties

value

The value of this MIME type, appropriate for Content-Type headers.

var value: String

bmp

let bmp

css

let css

csv

let csv

epub

let epub

gzip

let gzip

gif

let gif

html

let html

calendar

let calendar

jpeg

let jpeg

javascript

let javascript

json

let json

mid

let mid

mp3

let mp3

mpeg

let mpeg

octetStream

let octetStream

oga

let oga

ogv

let ogv

otf

let otf

pdf

let pdf

php

let php

plainText

let plainText

png

let png

rtf

let rtf

svg

let svg

tar

let tar

tiff

let tiff

ttf

let ttf

wav

let wav

xhtml

let xhtml

xml

let xml

zip

let zip
Alchemy
Types
Protocols
Global Typealiases
Global Variables
Global Functions
Fusion
Types
Protocols
Papyrus
Types
Protocols
Clone this wiki locally