0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

MIMEに関するメモ

Posted at

MIMEとは

Multipurpose Internet Mail Extensionsタイプの略称

インターネット上で送受信されるファイルの種類を識別するための標準的なフォーマット

MIMEタイプは、ブラウザやサーバーがファイルを正しく処理できるように、ファイルの内容を伝えるために使用されます

これにより、画像、テキスト、ビデオ、音声など、さまざまなファイルが正しく表示・再生されます

タイプ/サブタイプ

MIMEタイプはHTTPヘッダーの一部として、またはメールの送受信時に使用され、サーバーやクライアントが正しいアクション(表示、ダウンロード、実行など)を取れるようにする役割を果たします。

Content-Typeの例

htmlのレスポンス

HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Content-Length: 138
Connection: keep-alive

<html>
  <head>
    <title>Example</title>
  </head>
  <body>
    <h1>Hello, World!</h1>
  </body>
</html>

jsonのレスポンス

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 47
Connection: keep-alive

{
  "name": "John Doe",
  "age": 30
}

pdfのレスポンス

HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Disposition: attachment; filename="example.pdf"
Content-Length: 102400
Connection: keep-alive

(binary PDF data)

よくあるMIMEの書き方

テキスト形式ファイル

text/plain : プレーンテキストファイル
text/html : HTMLファイル

画像形式ファイル

image/jpeg : JPEG形式の画像
image/png : PNG形式の画像
image/gif : GIF形式の画像

動画形式ファイル

video/mp4 : MP4形式の動画
video/webm : WebM形式の動画

音声形式ファイル

audio/mpeg : MP3形式の音声
audio/ogg : OGG形式の音声

アプリケーション形式ファイル

application/json : JSONデータ
application/pdf : PDFファイル
application/zip : ZIP形式のアーカイブ

参考サイト

MIMEの書き方が多すぎて、全部覚える必要がないと思う~

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?