MIME-Type Rewriting

OpenGroupware Coils records the MIME type of a document, as provided by the client which creates it, as the object property {57c7fc84-3cea-417d-af54-b659eb87a046}contentType. In the case of a WebDAV, or any standards compliant HTTP client, this will be the value of the Content-Type header of the HTTP PUT operation. The value of this object property is used when the content-type is presented to any subsequent client.

If the content-type property does not exist or has a value of any of application/octet-string, application/octet-steam, or binary/octet-stream a guess of the type will be attempted based on the extension [if any] of the file-name. For example: if a document has no content-type property but the file-name of the document is "stanley.pdf” the server will assume the document has a MIME-type of application/pdf. The guess based on the file extension uses the server's CoilsExtensionMIMEMap default – this default is a dictionary which maps file extensions to PDFs.

MIME-Type Rewriting

Additionally, when presenting a document to a client, the server will check the MIME-type against the dictionary stored in the server's CoilsMIMETypeRewriteMap default. This default is used to implement MIME-type rewriting. Some clients may upload content using an invalid or obsolete MIME-type. For example a client may upload a document with a MIME-type of image/pdf. image/pdf is not a standard MIME-type and other clients may not deal with it properly - via MIME-type rewriting the server will present this MIME-type as application/pdf to subsequent client requests. If MIME-type rewriting is enabled for the MIME-type specified in an upload the rewritten MIME-type is included as the Content-Type header value of the upload response. MIME-type rewrite support is implemented for the Omphalos mimetype attribute of the File entity used by JSON-RPC and XML-RPC as well as in AttachFS and WebDAV protocols. Sites may override the built-in value of the CoilsMIMETypeRewriteMap default if they have additional MIME-types that require rewriting – if overriden the value must be a complete dictionary of types to rewrite, an site setting of the default replaces the built-in value, it is not additive.

{'image/pdf': 'application/pdf',
  'application/x-pdf': 'application/pdf',
  'applications/vnd.pdf': 'application/pdf',
  'text/pdf': 'application/pdf',
  'text/x-pdf': 'application/pdf',
  'application/acrobat': 'application/pdf',
  'binary/octet-stream': 'application/octet-stream', }

Text 1: The out-of-the-box value of the CoilsMIMETypeRewriteMap default.

Regardless of any rewriting of the MIME-type the server always stores the MIME-type as it was provided by the original request [at least until it is explicitly changed].

Tags: