I'm just designing the schema for a database table which will hold details of email attachments - their size in bytes, filename and content-type (i.e. "image/jpg", "audio/mp3", etc).
Does anybody know the maximum length that I can expect a content-type to be?
According to RFC 4288 "Media Type Specifications and Registration Procedures", type (eg. "application") and subtype (eg "vnd...") both can be max 127 characters. So including the slash, the maximum length is 255.
A media type (also known as a Multipurpose Internet Mail Extensions or MIME type) indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.
A media type (also known as a MIME type) is a two-part identifier for file formats and format contents transmitted on the Internet. The Internet Assigned Numbers Authority (IANA) is the official authority for the standardization and publication of these classifications.
MIME (Multipurpose Internet Mail Extensions) type is a standard way of describing a data type in the body of an HTTP message or email. The MIME type is passed in the Content-Type header. For example, the Content-Type: text/html header tells the browser that it received an HTML page.
I hope I havn't misread, but it looks like the length is max 127/127 or 255 total.
RFC 4288 has a reference in 4.2 (page 6):
Type and subtype names MUST conform to the following ABNF: type-name = reg-name subtype-name = reg-name reg-name = 1*127reg-name-chars reg-name-chars = ALPHA / DIGIT / "!" / "#" / "$" / "&" / "." / "+" / "-" / "^" / "_"
It is not clear to me if the +suffix can add past the 127, but it appears not.
In RFC 6838 which is latest standard and obsoletes RFC4288, there is a following statement.
"Also note that while this syntax allows names of up to 127 characters, implementation limits may make such long names problematic. For this reason, <type-name>
and <subtype-name>
SHOULD be limited to 64 characters."
64+1+64 = 129.
But I suspect the standard should mean 63+1+63=127.
link: https://www.rfc-editor.org/rfc/rfc6838#section-4.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With