1. MIME type

 

  Multipurpose Internet Mail Extensions의 약자로 간단히 말하면 파일 변환을 의미한다.

  현재는 웹을 통해 여러 형태의 파일을 전달하는데 사용하고 있다.

  이 용어가 처음 생겼을 땐 이메일과 함께 동봉할 파일을 텍스트 문자로 전환해서 이메일 시스템을 통해 전달하기 위해 개발되어 Internet Mail Extensions라고 불리기 시작했다고 한다.

 

 

 

2. MIME 사용 이유

 

  예전에는 텍스트 파일을 주고 받는데에 ASCII로 공통된 표준에 따르기만 하면 문제가 없었으나 네트워크를 통해 ASCII가 아닌 바이너리 파일을 보내는 경우가 생기게 되었다.

  음악파일, 무비파일, 워드파일 등등 ASCII만으로는 전송이 안되기 때문에 기존 시스템에서 문제 없이 전달하기 위해서는 텍스트로의 변환이 필요했다.

 

  텍스트 파일로 변환하는 것을 인코딩(Encoding), 텍스트 파일을 바이너리 파일로 변환하는 것을 디코딩(Decoding)이라고 한다.

  그리고 MIME으로 인코딩한 파일은 네트워크 통신을 할 때 Content-type정보를 앞부분에 담게되며 Content-type은 여러가지 타입이 있다. 브라우저는 Content-Type에 담긴 값을 토대로 디코딩을 해서 사용자의 화면에 보여줄 것이다

 

  예를 들어 웹 브라우저에서 서버에 접속하여 html 문서를 요청하면서 html문서에 있는 이미지 파일의 경로를 불러올 수 있다.

  이러한 과정에서 이미지의 경로에 있는 파일이 웹브라우저에서 지원되는 MIME-Type이라면 웹브라우저를 이용하여 열어볼 수 있다.

 

  바이너리파일(음악 파일, 무비 파일, 워드 파일 등) 또한 마찬가지 이다. 주로 쓰고 있는 대부분의 포맷인 .gif .jpg .mov 등등의 파일들은 웹 브라우저에서 무리없이 열리게 되는데 브라우저에서 지원하지 못하는 유형은 따로 지정해줘야 한다.

 

 

 

3. 다양한 Content-Type

 

  3 - 1) Multipart Related MIME 타입

    - Content-Type: Multipart/related <-- 기본형태

    - Content-Type: Application/X-FixedRecord

 

  3 - 2) XML Media의 타입

   - Content-Type: text/xml

   - Content-Type: Application/xml

   - Content-Type: Application/xml-external-parsed-entity

   - Content-Type: Application/xml-dtd

   - Content-Type: Application/mathtml+xml

   - Content-Type: Application/xslt+xml

 

  3 - 3) Application의 타입

    - Content-Type: Application/EDI-X12 <--  Defined in RFC 1767 

    - Content-Type: Application/EDIFACT <--  Defined in RFC 1767 

 

   - Content-Type: Application/javascript <-- Defined in RFC 4329 

   - Content-Type: Application/octet-stream  : <-- 디폴트 미디어 타입은 운영체제 종종 실행파일, 다운로드를 의미

   - Content-Type: Application/ogg <-- Defined in RFC 3534

   - Content-Type: Application/x-shockwave-flash <-- Adobe Flash files

   - Content-Type: Application/json <-- JavaScript Object Notation JSON; Defined in RFC 4627 

   - Content-Type: Application/x-www-form-urlencode <-- HTML Form 형태

 

  * x-www-form-urlencode와 multipart/form-data은 둘다 폼 형태이지만 x-www-form-urlencode은 대용량 바이너리 테이터를 전송하기에 비효율적이기 때문에 대부분 첨부파일은 multipart/form-data를 사용하게 된다.

 

  3 - 4) 오디오 타입

    - Content-Type: audio/mpeg <-- MP3 or other MPEG audio

    - Content-Type: audio/x-ms-wma <-- Windows Media Audio;

    - Content-Type: audio/vnd.rn-realaudio <--  RealAudio;  등등 

 

  3 - 5) Multipart 타입

    - Content-Type: multipart/mixed: MIME E-mail; 

    - Content-Type: multipart/alternative: MIME E-mail;

    - Content-Type: multipart/related: MIME E-mail <-- Defined in RFC 2387 and used by MHTML(HTML mail) 

    - Content-Type: multipart/formed-data  <-- 파일 첨부

 

  3 - 6) TEXT 타입

    - Content-Type: text/css

    - Content-Type: text/html

    - Content-Type: text/javascript

    - Content-Type: text/plain

    - Content-Type: text/xml

 

  3 - 7) file 타입

    - Content-Type: application/msword <-- doc

    - Content-Type: application/pdf <-- pdf

    - Content-Type: application/vnd.ms-excel <-- xls

    - Content-Type: application/x-javascript <-- js

    - Content-Type: application/zip <-- zip

    - Content-Type: image/jpeg <-- jpeg, jpg, jpe

    - Content-Type: text/css <-- css

    - Content-Type: text/html <-- html, htm

    - Content-Type: text/plain <-- txt

    - Content-Type: text/xml <-- xml

    - Content-Type: text/xsl <-- xsl

 

 

*참고 : velog.io/@aerirang647/MIME-type%EC%9D%B4%EB%9E%80,

yunzema.tistory.com/186

'CodeStates' 카테고리의 다른 글

IM 35일차 (nodemon & Debugging for node.js)  (0) 2021.02.15
IM 32일차 (Postman 사용법)  (0) 2021.02.12
IM 26일차 (CORS)  (0) 2021.02.06
IM 25일차 (http)  (0) 2021.02.06
IM 24일차 (Basic Web Architecture, Ajax)  (0) 2021.02.05

+ Recent posts