What are MIME types
Points To Remeber
  • MIME stands for Multi-purpose Internet Mail Extensions.
  • MIME is an extension of the original Internet e-mail protocol that lets people use the protocol to exchange different kinds of data files on the Internet: audio, video, images, application programs
  • MIME types were originally used to send different file types through email services over SMT SMTP(Simple Mail Transfer Protocal) protocal.
  •  MIME types form a standard way of classifying file types on the Internet e.g. using the "Content-type" header value defined in a HTTP response, the browser can open the file with the proper extension/plugin. 
  •  Internet programs such as Web servers and browsers all have a list of MIME types, so that they can transfer files of the same type in the same way, irrespective of what operating system they are working in.
How does a MIME type look like ??
There are two parts in a MIME type a type and a subtype, and they are seperated by a slash '/' in between.
  1. Type - It represent the type of file that is being used e.g application, audio, text etc.
  2. Subtype - It represents the file type of the file being used. eg msword, html , plain , zip etc.
MIME type Prefixes
  • MIME Prefixed with "x-" The "x-" prefix of a MIME subtype simply means that it's non-standard, i.e not registered with the "Internet Assigned Numbers Authority".
  • MIME Prefixed with "vnd-" The "vnd-" prefix means that the MIME value is vendor specific and is not a registered MIME type.   
How to set Content-Type  header of my files ??
  • Setting the Content-type in ASP: 
    <% response.ContentType="text/html" %>
  • Setting the Content-type in C#: 
    // Response is of type System.Web.HttpResponse
    response.ContentType = "text/plain";
  • Setting the Content-type in Java: 
    // Response is of type javax.servlet.ServletReponse
  • Setting the Content-type in Perl/CGI:  
    print "Content-type:text/html";
  • Setting the Content-type in PHP:  
    <?php header('Content-type: text/html');?>

No comments :

Post a Comment