Login Login
MORE

WIDGETS

Widgets

Wanted articles
Who is online?
Article tools

Programmazione:MIME types

From Aino Wiki

Jump to: navigation, search

Elenco

I MIME type primari sono due:

  • text/plain è il valore di default per i files di testo. Questi files sono umanamente leggibili e non devono contenere dati binari.
  • application/octet-stream è il tipo di default per tutti gli altri tipi che non siano i files di tipo testo.

L'IANA è il registro dei media type e ne mantiene una lista ufficiale lista

Elenco per il Web

Extension Kind of document MIME Type
.aac AAC audio audio/aac
.abw AbiWord document application/x-abiword
.arc Archive document (multiple files embedded) application/x-freearc
.avi AVI: Audio Video Interleave video/x-msvideo
.azw Amazon Kindle eBook format application/vnd.amazon.ebook
.bin Any kind of binary data application/octet-stream
.bmp Windows OS/2 Bitmap Graphics image/bmp
.bz BZip archive application/x-bzip
.bz2 BZip2 archive application/x-bzip2
.csh C-Shell script application/x-csh
.css Cascading Style Sheets (CSS) text/css
.csv Comma-separated values (CSV) text/csv
.doc Microsoft Word application/msword
.docx Microsoft Word (OpenXML) application/vnd.openxmlformats-officedocument.wordprocessingml.document
.eot MS Embedded OpenType fonts application/vnd.ms-fontobject
.epub Electronic publication (EPUB) application/epub+zip
.gz GZip Compressed Archive application/gzip
.gif Graphics Interchange Format (GIF) image/gif
.htm
.html
HyperText Markup Language (HTML) text/html
.ico Icon format image/vnd.microsoft.icon
.ics iCalendar format text/calendar
.jar Java Archive (JAR) application/java-archive
.jpeg
.jpg
JPEG images image/jpeg
.js JavaScript

text/javascript, per the following specifications:

.json JSON format application/json
.jsonld JSON-LD format application/ld+json
.mid
.midi
Musical Instrument Digital Interface (MIDI) audio/midi audio/x-midi
.mjs JavaScript module text/javascript
.mp3 MP3 audio audio/mpeg
.mpeg MPEG Video video/mpeg
.mpkg Apple Installer Package application/vnd.apple.installer+xml
.odp OpenDocument presentation document application/vnd.oasis.opendocument.presentation
.ods OpenDocument spreadsheet document application/vnd.oasis.opendocument.spreadsheet
.odt OpenDocument text document application/vnd.oasis.opendocument.text
.oga OGG audio audio/ogg
.ogv OGG video video/ogg
.ogx OGG application/ogg
.opus Opus audio audio/opus
.otf OpenType font font/otf
.png Portable Network Graphics image/png
.pdf Adobe Portable Document Format (PDF) application/pdf
.php Hypertext Preprocessor (Personal Home Page) application/x-httpd-php
.ppt Microsoft PowerPoint application/vnd.ms-powerpoint
.pptx Microsoft PowerPoint (OpenXML) application/vnd.openxmlformats-officedocument.presentationml.presentation
.rar RAR archive application/vnd.rar
.rtf Rich Text Format (RTF) application/rtf
.sh Bourne shell script application/x-sh
.svg Scalable Vector Graphics (SVG) image/svg+xml
.swf Small web format (SWF) or Adobe Flash document application/x-shockwave-flash
.tar Tape Archive (TAR) application/x-tar
.tif
.tiff
Tagged Image File Format (TIFF) image/tiff
.ts MPEG transport stream video/mp2t
.ttf TrueType Font font/ttf
.txt Text, (generally ASCII or ISO 8859-n) text/plain
.vsd Microsoft Visio application/vnd.visio
.wav Waveform Audio Format audio/wav
.weba WEBM audio audio/webm
.webm WEBM video video/webm
.webp WEBP image image/webp
.woff Web Open Font Format (WOFF) font/woff
.woff2 Web Open Font Format (WOFF) font/woff2
.xhtml XHTML application/xhtml+xml
.xls Microsoft Excel application/vnd.ms-excel
.xlsx Microsoft Excel (OpenXML) application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xml XML application/xml if not readable from casual users (RFC 3023, section 3)
text/xml if readable from casual users (RFC 3023, section 3)
.xul XUL application/vnd.mozilla.xul+xml
.zip ZIP archive application/zip
.3gp 3GPP audio/video container video/3gpp
audio/3gpp if it doesn't contain video
.3g2 3GPP2 audio/video container video/3gpp2
audio/3gpp2 if it doesn't contain video
.7z 7-zip archive application/x-7z-compressed

Metodo C#

        public static string GetMimeType(string fileName)
        {
            string mimeType = "application/unknown";
            string ext = System.IO.Path.GetExtension(fileName).ToLower();
            switch (ext)
            {
                case ".aac":
                    mimeType = "audio/aac";
                    break;
                case ".abw":
                    mimeType = "application/x-abiword";
                    break;
                case ".arc":
                    mimeType = "application/x-freearc";
                    break;
                case ".avi":
                    mimeType = "video/x-msvideo";
                    break;
                case ".azw":
                    mimeType = "application/vnd.amazon.ebook";
                    break;
                case ".bin":
                    mimeType = "application/octet-stream";
                    break;
                case ".bmp":
                    mimeType = "image/bmp";
                    break;
                case ".bz":
                    mimeType = "application/x-bzip";
                    break;
                case ".bz2":
                    mimeType = "application/x-bzip2";
                    break;
                case ".csh":
                    mimeType = "application/x-csh";
                    break;
                case ".css":
                    mimeType = "text/css";
                    break;
                case ".csv":
                    mimeType = "text/csv";
                    break;
                case ".doc":
                    mimeType = "application/msword";
                    break;
                case ".docx":
                    mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
                    break;
                case ".eot":
                    mimeType = "application/vnd.ms-fontobject";
                    break;
                case ".epub":
                    mimeType = "application/epub+zip";
                    break;
                case ".gz":
                    mimeType = "application/gzip";
                    break;
                case ".gif":
                    mimeType = "image/gif";
                    break;
                case ".htm":
                    mimeType = "text/html";
                    break;
                case ".html":
                    mimeType = "text/html";
                    break;
                case ".ico":
                    mimeType = "image/vnd.microsoft.icon";
                    break;
                case ".ics":
                    mimeType = "text/calendar";
                    break;
                case ".jar":
                    mimeType = "application/java-archive";
                    break;
                case ".jpeg":
                    mimeType = "image/jpeg";
                    break;
                case ".jpg":
                    mimeType = "image/jpeg";
                    break;
                case ".js":
                    mimeType = "text/javascript";
                    break;
                case ".json":
                    mimeType = "application/json";
                    break;
                case ".jsonld":
                    mimeType = "application/ld+json";
                    break;
                case ".mid":
                    mimeType = "audio/midi audio/x-midi";
                    break;
                case ".midi":
                    mimeType = "audio/midi audio/x-midi";
                    break;
                case ".mjs":
                    mimeType = "text/javascript";
                    break;
                case ".mp3":
                    mimeType = "audio/mpeg";
                    break;
                case ".mpeg":
                    mimeType = "video/mpeg";
                    break;
                case ".mpkg":
                    mimeType = "application/vnd.apple.installer+xml";
                    break;
                case ".odp":
                    mimeType = "application/vnd.oasis.opendocument.presentation";
                    break;
                case ".ods":
                    mimeType = "application/vnd.oasis.opendocument.spreadsheet";
                    break;
                case ".odt":
                    mimeType = "application/vnd.oasis.opendocument.text";
                    break;
                case ".oga":
                    mimeType = "audio/ogg";
                    break;
                case ".ogv":
                    mimeType = "video/ogg";
                    break;
                case ".ogx":
                    mimeType = "application/ogg";
                    break;
                case ".opus":
                    mimeType = "audio/opus";
                    break;
                case ".otf":
                    mimeType = "font/otf";
                    break;
                case ".png":
                    mimeType = "image/png";
                    break;
                case ".pdf":
                    mimeType = "application/pdf";
                    break;
                case ".php":
                    mimeType = "application/x-httpd-php";
                    break;
                case ".ppt":
                    mimeType = "application/vnd.ms-powerpoint";
                    break;
                case ".pptx":
                    mimeType = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
                    break;
                case ".rar":
                    mimeType = "application/vnd.rar";
                    break;
                case ".rtf":
                    mimeType = "application/rtf";
                    break;
                case ".sh":
                    mimeType = "application/x-sh";
                    break;
                case ".svg":
                    mimeType = "image/svg+xml";
                    break;
                case ".swf":
                    mimeType = "application/x-shockwave-flash";
                    break;
                case ".tar":
                    mimeType = "application/x-tar";
                    break;
                case ".tif":
                    mimeType = "image/tiff";
                    break;
                case ".tiff":
                    mimeType = "image/tiff";
                    break;
                case ".ts":
                    mimeType = "video/mp2t";
                    break;
                case ".ttf":
                    mimeType = "font/ttf";
                    break;
                case ".txt":
                    mimeType = "text/plain";
                    break;
                case ".vsd":
                    mimeType = "application/vnd.visio";
                    break;
                case ".wav":
                    mimeType = "audio/wav";
                    break;
                case ".weba":
                    mimeType = "audio/webm";
                    break;
                case ".webm":
                    mimeType = "video/webm";
                    break;
                case ".webp":
                    mimeType = "image/webp";
                    break;
                case ".woff":
                    mimeType = "font/woff";
                    break;
                case ".woff2":
                    mimeType = "font/woff2";
                    break;
                case ".xhtml":
                    mimeType = "application/xhtml+xml";
                    break;
                case ".xls":
                    mimeType = "application/vnd.ms-excel";
                    break;
                case ".xlsx":
                    mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                    break;
                case ".xml":
                    mimeType = "application/xml";
                    break;
                case ".xul":
                    mimeType = "application/vnd.mozilla.xul+xml";
                    break;
                case ".zip":
                    mimeType = "application/zip";
                    break;
                case ".3gp":
                    mimeType = "video/3gpp";
                    break;
                case ".3g2":
                    mimeType = "video/3gpp2";
                    break;
                case ".7z":
                    mimeType = "application/x-7z-compressed";
                    break;
                default:
                    break;
            }
            return mimeType;
        }

Mappa e Link


Documentazione ed Help



Parole chiave:

Author