Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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://tools.ietf.org/html/rfc6838#section-4.2

We run an SaaS system that allows users to upload files. We'd originally designed it to store MIME Types up to 50 characters. In the last several days we've seen several attempts to upload 71-bytes types. So, we're changing to 250. 100 seemed "good" but it's only a few more than the max we're seeing now. 500 seems silly, so 250 is the selected one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top