tags:

views:

2147

answers:

6

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?

+3  A: 

This chart shows you a list of common MIME types and their corresponding file extensions. They can all be used as content-types.

Espo
+1: Deserved more than just one upvote!
KMan
A: 

Some mime types take arguments on the content-type field seperated by semi-colons and can be pretty long.

sparkes
A: 

From having a quick read of the specification there doesn't appear to be any limit on the length:

http://www.w3.org/Protocols/rfc1341/4_Content-Type.html

http://en.wikipedia.org/wiki/MIME#Content-Type

Mark Ingram
+1  A: 

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.

WaldenL
+1  A: 

I've got an exception when trying to add this type:

application/vnd.openxmlformats-officedocument.wordprocessingml.document

(length 71) into my varchar(50). File extension .docx

googling gave me even longer (80): application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml

+4  A: 

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.

speaker