IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

Mettre en oeuvre un "Ouvrir Avec"


Sujet :

JavaScript

  1. #1
    Membre éprouvé Avatar de Zebulon777
    Homme Profil pro
    Informaticien
    Inscrit en
    Février 2005
    Messages
    1 327
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Informaticien

    Informations forums :
    Inscription : Février 2005
    Messages : 1 327
    Par défaut Mettre en oeuvre un "Ouvrir Avec"
    Bonjour tout le monde.

    Ca fait plus de 3 jours que je tourne en rond avec une fonctionnalité et je craque, donc et vous demande votre aide.

    Dans l'application que nous développons, on doit proposer à l'utilisateur d'ouvrir ou de télécharger certains fichier (TXT, CSV, XLS ou XLSX) disponibles sur le serveur.
    Je cherche donc à reproduire la boite "Ouvrir avec..." qui fait exactement ce qu'on veux.
    On a donc une fonction qui remplie une table avec un bouton en dernière cellule de chaque ligne.
    Une des cellules de la table contient le nom complet du fichier à récupérer ou à ouvrir et est dans la variable WFic.
    (Cette variable est forcée à cause du confinement, car je n'ai pas accès au serveur).
    Mais je n'arrive pas à implémenter la fonction d'ouverture.
    J'ai bien pensé au download du html5, mais ça ne fonctionne pas.

    J'espère que je suis clair dans mes explications et merci d'avance pour votre précieuse aide.

    Voici la fonction brut
    Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
     
    function VerificationFichier(P_Champs01)
    {
    	writeFile(G_FICLOG, "VerificationFichier(P_Champs01)", "OUI");
     
    	let WNomFic = P_Champs01[28];
    	let WDateDeb = $('#date_deb').datepicker("getDate");
    	let WDateFin = $('#date_fin').datepicker("getDate");
    	let WNomFicATraiter = RecupFormat(WNomFic, WDateDeb); // Récupère le format de la date dans le nom du fichier et on remplace par WDateDeb
    	let WLigne = $('#ds_clair').html() + Remplace(WNomFicATraiter, "categorie", WChamps01[27]);
    	$('#verif').html(WLigne);
     
    	SelectParametre("NB_FICHIER_SRC_MAX");
    	let WNb_FichierSRC = parseInt(G_SELECT_PARAMETRE);
    	let f = 0;
    	let WNumLig = 1;
    	let WDossier = "";
    	let WDate = "";
    	let WNomComplet = "";
    	let WNomFic2 = "";
    	let WDos = "";
    	let WDos2 = "";
     
    // Vidage de table_depend en laissant la 1ère ligne (on laisse les thead, mais on supprimer les tbody)
    	$("#table_depend tbody").empty();	
    	while (f <= WNb_FichierSRC)
    	{
    		if (P_Champs01[f] != "") // META_FICHIER_SRC_n
    		{
    			let B_DateDeb = new Date(WDateDeb);
    			let B_DateFin = new Date(WDateFin);
    			while (B_DateDeb <= B_DateFin)
    			{
    				let WDateDeb2 = FormatDate2(B_DateDeb, "JJ/MM/AAAA")
    				let WPos = P_Champs01[f].indexOf("_backslash_");
    				let WPosFin = WPos + 11; // "_backslash_" -> 11 caractères
    				if (WPos != -1)
    				{
    					WDos = P_Champs01[f].substr(0, WPos);
    					if (WDos.indexOf("DOSSIER") != -1)
    					{
    						WNomFic2 = P_Champs01[f].substr(WPosFin, P_Champs01[f].length);
    						SelectParametre(WDos);
    						WDos2 = G_SELECT_PARAMETRE;
    					}
    					else
    					{
    						WNomFic2 = Remplace(P_Champs01[f], "_backslash_", "\\");
    					}
    				}
    				else
    				{
    					WDos = "";
    					WNomFic2 = P_Champs01[f];
    				};
    				WNomComplet = RecupFormat(WNomFic2, B_DateDeb); //WNomFic2;
    				let WFic = WDos2 + WNomComplet;
     
    //WNomFicATraiter = "/volume1/web/CTRL_BDD_MULTIVAC_SG/LOG/2020_04_07_LOG_CTRL_BDD_MULTIVAC_SG.txt";
    if (f == 2 || f == 4 || f == 6)
    {
    	WFic = "/volume1/web/CTRL_BDD_MULTIVAC_SG/LOG/2020_04_10_LOG_CTRL_BDD_MULTIVAC_SG.txt";
    }
    				let WLigTableDepend = document.createElement("tr");
    				WLigTableDepend.id = "DL" + twoDigit(WNumLig);
     
    				let WCell01 = document.createElement("td");
    				WCell01.id = "DL" + twoDigit(WNumLig) + "C01";
    //				WCell01.innerHTML = P_Champs01[f];
    				let PWCell01 = document.createElement("label");
    				PWCell01.innerHTML = P_Champs01[f];
    				WCell01.appendChild(PWCell01);
    				let WCell02 = document.createElement("td");
    				WCell02.id = "DL" + twoDigit(WNumLig) + "C02";
    				WCell02.innerHTML = WDateDeb2;
    				let WCell03 = document.createElement("td");
    				WCell03.id = "DL" + twoDigit(WNumLig) + "C03";
    				WCell03.innerHTML = WFic;
    				let WCell04 = document.createElement("td");
    				let BtnCell04 = document.createElement("button");
    				BtnCell04.title = "Ouverture du fichier : \r\n" + WFic;
    				BtnCell04.onclick = function()
    				{
    					OuvreFic(WFic);
    				};
    				WCell04.id = "DL" + twoDigit(WNumLig) + "C04";
    //				WCell04.appendChild(BtnCell04);
    				let Wa = document.createElement("a");
    				Wa.setAttribute("download_bis", WFic);
    				Wa.appendChild(BtnCell04);
    				WCell04.appendChild(Wa);
    				WLigTableDepend.appendChild(WCell01);
    				WLigTableDepend.appendChild(WCell02);
    				WLigTableDepend.appendChild(WCell03);
    				WLigTableDepend.appendChild(WCell04);
     
    				PWCell01.className = "wrapping"; // On applique la classe au <P> dans la cellule
    				WCell01.className = "CentrageVerticalForce";
    				WCell02.className = "CentrageVerticalForce";
    				WCell03.className = "CentrageVerticalForce";
    				BtnCell04.className = "btn btn-warning fas fa-folder-open fa-lg center";
    				WCell04.classList.add("text-center");
    				WCell04.classList.add("Table_Largeur_Col1");
    				WCell04.className = "CentrageVerticalForce";
     
    				document.getElementById("dependRows").append(WLigTableDepend);
    				document.getElementById("DL" + twoDigit(WNumLig)).onclick = function()
    				{
    					$("#table_caract tbody").empty();	
    					tableControl("table_depend", WLigTableDepend.id, "FondBordeau", "LIG");
    					AffNiveau2(this.id, this.rowIndex, P_Champs01, WFic);
    				}
     
    				fileExists(WFic, "NON");
    				if (G_FILE_EXIST == "OK")
    				{
    					WCell01.classList.add("FondVert");			
    					WCell02.classList.add("FondVert");			
    					WCell03.classList.add("FondVert");			
    					WCell04.classList.add("FondVert");
    					BtnCell04.disabled = false;
    				}
    				else
    				{
    					WCell01.classList.add("FondRouge");			
    					WCell02.classList.add("FondRouge");			
    					WCell03.classList.add("FondRouge");			
    					WCell04.classList.add("FondRouge");			
    					BtnCell04.disabled = true;
    				}
     
    				B_DateDeb = new Date(B_DateDeb.setDate(B_DateDeb.getDate()+1));
    			};
    		}
    		WNumLig = WNumLig + 1;
    		f = f + 1;
    	}
    ...
    ...
    ...

    Les essais en PHP :
    Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
     
    function OuvreFic(P_Fichier)
    {
    	writeFile(G_FICLOG, "OuvreFic(" + P_Fichier + ")", "OUI");
     
    	alert("Ouverture du fichier : " + P_Fichier);
     
    //	download_bis(P_Fichier, "il faut lire le fichier texte pour le charger");
     
        $.ajax(
        {
            type: "POST",
            url: "./PHP/Download.php",
            data: {NomFichier : P_Fichier},
            async: false,
            error : function()
            {
     
                alert("Echec de l'envoi de la requête : " + P_Fichier);
            },
            success: function(data)
            {
    //			console.log("envoyé avec succès");
            }
        });
    }

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    <?php
    	$file = $_POST['NomFichier'];
     
    	header('Content-Transfer-Encoding: binary');
    	header('Content-Disposition: attachment; filename="'.'im.jpg'.'"'); //Nom du fichier
    	header('Content-Length: '.intval('82927')); // Taille du fichier
     
    	//readfile('/volume1/web/CTRL_BDD_MULTIVAC_SG/LOG/2020_04_10_LOG_CTRL_BDD_MULTIVAC_SG.txt');// nom (et emplacement) du fichier dans le serveur
    	readfile($file);// nom (et emplacement) du fichier dans le serveur
     
    ?>

    Je précise que j'essaye 2 trucs à la fois : une fonction "OuvreFic" au click sur le bouton d'un côté et un ajout du ciode HTML5 DONWLOAD.

    Bref, j'espère que vous pourrez m'aider à me dépatouiller de ce truc et ces temps compliqués.

  2. #2
    Expert confirmé
    Avatar de Watilin
    Homme Profil pro
    En recherche d'emploi
    Inscrit en
    Juin 2010
    Messages
    3 100
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : En recherche d'emploi

    Informations forums :
    Inscription : Juin 2010
    Messages : 3 100
    Par défaut
    Salut,
    les infos sur l’attribut download ne sont pas complètement évidentes à trouver sur le MDN, elles sont en réalité données sur la page de <a> : https://developer.mozilla.org/fr/doc...HTML/Element/a
    Il y est indiqué notamment que si le serveur envoie un en-tête Content-Disposition, l’attribut download sera ignoré.
    Ceci est, tu t’en doutes, une mesure de sécurité car le code client (supposé non sûr) ne doit pas pouvoir outrepasser les directives du serveur (supposé sûr).

    Dans cette même idée de sécurité, JavaScript ne peut pas connaître les logiciels ou applications installées sur la machine cliente, et c’est le navigateur lui-même qui décide de ce qu’il doit faire lorsqu’un fichier lui est présenté pour enregistrement. L’utilisateur ou l’utilisatrice peut ajuster ce comportement dans les paramètres de son navigateur ; mais toi, en tant que développeur du site, tu n’y as malheureusement pas accès.

    Je te conseille de rajouter un en-tête Content-Type indiquant le type MIME du fichier (j’ai trouvé une liste ici), ça devrait, en théorie, aider le navigateur à proposer la bonne application pour ouvrir le fichier.

    Edit : parce qu’on ne sait jamais quand un lien devient invalide, je copie ici les passages de la liste sus-dite qui nous intéressent :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    .xls      application/vnd.ms-excel
    .xlsx     application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
    Également, pour les formats plus simples :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    .txt    text/plain
    .csv    text/csv
    Pour les formats text/*, il est possible (et conseillé) de préciser l’encodage : ; charset=utf-8 par exemple.

    Question hors sujet : as-tu une raison particulière d’utiliser async: false ?
    La FAQ JavaScript – Les cours JavaScript
    Touche F12 = la console → l’outil indispensable pour développer en JavaScript !

  3. #3
    Membre éprouvé Avatar de Zebulon777
    Homme Profil pro
    Informaticien
    Inscrit en
    Février 2005
    Messages
    1 327
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Informaticien

    Informations forums :
    Inscription : Février 2005
    Messages : 1 327
    Par défaut
    Merci de te pencher sur mon cas.

    Je reprends après ces 3 jours de "congés".

    J'essaye de suivre tes conseils, mais ça ne fonctionne toujours pas.

    Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
     
    function OuvreFic(P_Fichier)
    {
    	writeFile(G_FICLOG, "OuvreFic(" + P_Fichier + ")", "OUI");
     
    	alert("Ouverture du fichier : " + P_Fichier);
     
    //	download_bis(P_Fichier, "il faut lire le fichier texte pour le charger");
     
        $.ajax(
        {
            type: "POST",
            url: "./PHP/Download.php",
            data: {NomFichier : P_Fichier},
            async: false,
            error : function()
            {
                alert("Echec de l'envoi de la requête : " + P_NomFichier);
            },
            success: function(data)
            {
    console.log("OuvreFic - SUCCESS Donwload.php - "+P_Fichier+" - "+data);
    //			console.log("envoyé avec succès");
            }
        });
    }

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
     
    <?php
    	$file = $_POST['NomFichier'];
     
    	header('Content-Transfer-Encoding: binary');
    	header('Content-Disposition: attachment; filename="' . $file . '"'); //Nom du fichier
    	header("Content-type: text/plain; charset=utf-8"); 
    	header("Content-type: text/csv; charset=utf-8"); 
    	header("Content-type: application/vnd.ms-excel");
     
    	//readfile('/volume1/web/CTRL_BDD_MULTIVAC_SG/LOG/2020_04_10_LOG_CTRL_BDD_MULTIVAC_SG.txt');// nom (et emplacement) du fichier dans le serveur
     
    	readfile($file);// nom (et emplacement) du fichier dans le serveur
     
    ?>

    PS : Je suis en mode synchrone car je ne veux pas que le script se poursuive pendant cet fonction.

    C'est dingue, je suis complètement coincé avec cette fonction de chargement de fichier alors que je ne m'y attendais pas du tout.

    En tout cas, merci d'essayer de m'aider.

  4. #4
    Expert confirmé
    Avatar de Watilin
    Homme Profil pro
    En recherche d'emploi
    Inscrit en
    Juin 2010
    Messages
    3 100
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : En recherche d'emploi

    Informations forums :
    Inscription : Juin 2010
    Messages : 3 100
    Par défaut
    Ce que j’essayais de te dire dans mon précédent post, c’est qu’il n’y a pas de solution à ton problème.
    Tout ce que tu peux faire, c’est t’arranger pour que l’expérience soit à peu près cohérente d’un navigateur à l’autre, par exemple comme je t’ai dit en envoyant un “type hint”, une indication de type MIME, que le navigateur utilisera pour proposer une action à l’utilisateur ou utilisatrice. Chrome est assez opaque sur ce point, c’est plus clair avec Firefox : si tu regardes dans les préférences, il y a une catégorie « Applications » qui présente différents types de fichier et les actions associées.

    Voici deux exemples de type hint :
    Code PHP : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <?php
    header('Content-Disposition: attachment');
    header('Content-Type: text/plain');
     
    // juste pour ce test : désactive le cache
    // ne pas utiliser tel quel en production
    header('Cache-Control: no-cache');
     
    echo 'Test';

    Avec le code ci-dessus, il y a des chances que le navigateur propose d’ouvrir le fichier avec un éditeur de texte. Ou pas. Je me répète, ça dépend de la configuration du navigateur, et tu n’as pas de contrôle dessus.
    En revanche,

    Code PHP : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <?php
    header('Content-Disposition: attachment');
    header('Content-Type: application/octet-stream');
     
    // juste pour ce test : désactive le cache
    // ne pas utiliser tel quel en production
    header('Cache-Control: no-cache');
     
    echo 'Test';

    Ici, le serveur envoie le type MIME application/octet-stream qui est le type le plus générique possible, qui n’est en principe associé à aucune application par défaut. Sauf configuration spéciale, le navigateur proposera toujours de l’enregistrer, jamais de l’ouvrir avec une application.

    Remarque, dans ton code, tu as mis plusieurs Content-Type, or il ne peut y en avoir qu’un seul. Le dernier écrasera les précédents.

    Pour déterminer quel type envoyer, tu peux au choix :
    • te baser sur l’extension de fichier ;
    • utiliser une fonction de détection de type telle que fileinfo::file.


    Attention, tu as un problème de sécurité dans ton code : tu utilises une donnée POST comme chemin de fichier. Un attaquant peut utiliser des chemins absolus ou comportant ../ pour tenter d’accéder à des fichiers sensibles. Je te conseille de choisir un dossier autorisé et, en utilisant SplFileInfo::getRealPath, de comparer le chemin demandé au chemin du dossier autorisé.
    La FAQ JavaScript – Les cours JavaScript
    Touche F12 = la console → l’outil indispensable pour développer en JavaScript !

  5. #5
    Membre éprouvé Avatar de Zebulon777
    Homme Profil pro
    Informaticien
    Inscrit en
    Février 2005
    Messages
    1 327
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Informaticien

    Informations forums :
    Inscription : Février 2005
    Messages : 1 327
    Par défaut
    Merci beaucoup pour tous ces conseils.

    Nous n'avons pas de problème de sécurité parce que cette application ne fonctionne qu'en intranet.
    Ca limite, même si je note tout ça ; j'apprends

    j'ai pas mal avancé, surtout grâce à des recherches sur le net et je suis tombé sur ce script qui correspond exactement à ce que nous voulons faire.
    Mais le souci, c'est qu'il faut absolument passer par un bouton "Parcourir".

    Je cherche donc à remplacer la sélection par le bouton "Parcourir" par le nom du fichier directement, mais pour le moment, c'est chou blanc.
    D'ailleurs est-ce que c'est possible ?

    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <input type="file" id="fileinput" />
    <p>
      <a id="download" download></a>
    </p>
    Code css : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    * {
      font-family: arial;
    }
     
    #doc {
      width: 300px;
      height: 400px;
    }
     
    a {
      color: BLACK;
      text-decoration: NONE;
    }
     
    a:hover {
      color: BLUE;
      text-decoration: UNDERLINE;
      font-size: 30px;
      font-family: times;
    }
    Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    893
    894
    895
    896
    897
    898
    899
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    930
    931
    932
    933
    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    950
    951
    952
    953
    954
    955
    956
    957
    958
    959
    960
    961
    962
    963
    964
    965
    966
    967
    968
    969
    970
    971
    972
    973
    974
    975
    976
    977
    978
    979
    980
    981
    982
    983
    984
    985
    986
    987
    988
    989
    990
    991
    992
    993
    994
    995
    996
    997
    998
    999
    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    1026
    1027
    1028
    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    1040
    1041
    1042
    1043
    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    1061
    1062
    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    1080
    1081
    1082
    1083
    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    1097
    1098
    1099
    1100
    1101
    1102
    1103
    1104
    1105
    1106
    1107
    1108
    1109
    1110
    1111
    1112
    1113
    1114
    1115
    1116
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    1124
    1125
    1126
    1127
    1128
    1129
    1130
    1131
    1132
    1133
    1134
    1135
    1136
    1137
    1138
    1139
    1140
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    1150
    1151
    1152
    1153
    1154
    1155
    1156
    1157
    1158
    1159
    1160
    1161
    1162
    1163
    1164
    1165
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    1176
    1177
    1178
    1179
    1180
    1181
    1182
    1183
    1184
    1185
    1186
    1187
    1188
    1189
    1190
    1191
    1192
    1193
    1194
    1195
    1196
    1197
    1198
    1199
    1200
    1201
    1202
    1203
    1204
    1205
    1206
    1207
    1208
    1209
    1210
    1211
    1212
    1213
    1214
    1215
    1216
    1217
    1218
    1219
    1220
    1221
    1222
    1223
    1224
    1225
    1226
    1227
    1228
    1229
    1230
    1231
    1232
    1233
    1234
    1235
    1236
    1237
    1238
    1239
    1240
    1241
    1242
    1243
    1244
    1245
    1246
    1247
    1248
    1249
    1250
    1251
    1252
    1253
    1254
    1255
    1256
    1257
    1258
    1259
    1260
    1261
    1262
    1263
    1264
    1265
    1266
    1267
    1268
    1269
    1270
    1271
    1272
    1273
    1274
    1275
    1276
    1277
    1278
    1279
    1280
    1281
    1282
    1283
    1284
    1285
    1286
    1287
    1288
    1289
    1290
    1291
    1292
    1293
    1294
    1295
    1296
    1297
    1298
    1299
    1300
    1301
    1302
    1303
    1304
    1305
    1306
    1307
    1308
    1309
    1310
    1311
    1312
    1313
    1314
    1315
    1316
    1317
    1318
    1319
    1320
    1321
    1322
    1323
    1324
    1325
    1326
    1327
    1328
    1329
    1330
    1331
    1332
    1333
    1334
    1335
    1336
    1337
    1338
    1339
    1340
    1341
    1342
    1343
    1344
    1345
    1346
    1347
    1348
    1349
    1350
    1351
    1352
    1353
    1354
    1355
    1356
    1357
    1358
    1359
    1360
    1361
    1362
    1363
    1364
    1365
    1366
    1367
    1368
    1369
    1370
    1371
    1372
    1373
    1374
    1375
    1376
    1377
    1378
    1379
    1380
    1381
    1382
    1383
    1384
    1385
    1386
    1387
    1388
    1389
    1390
    1391
    1392
    1393
    1394
    1395
    1396
    1397
    1398
    1399
    1400
    1401
    1402
    1403
    1404
    1405
    1406
    1407
    1408
    1409
    1410
    1411
    1412
    1413
    1414
    1415
    1416
    1417
    1418
    1419
    1420
    1421
    1422
    1423
    1424
    1425
    1426
    1427
    1428
    1429
    1430
    1431
    1432
    1433
    1434
    1435
    1436
    1437
    1438
    1439
    1440
    1441
    1442
    1443
    1444
    1445
    1446
    1447
    1448
    1449
    1450
    1451
    1452
    1453
    1454
    1455
    1456
    1457
    1458
    1459
    1460
    1461
    1462
    1463
    1464
    1465
    1466
    1467
    1468
    1469
    1470
    1471
    1472
    1473
    1474
    1475
    1476
    1477
    1478
    1479
    1480
    1481
    1482
    1483
    1484
    1485
    1486
    1487
    1488
    1489
    1490
    1491
    1492
    1493
    1494
    1495
    1496
    1497
    1498
    1499
    1500
    1501
    1502
    1503
    1504
    1505
    1506
    1507
    1508
    1509
    1510
    1511
    1512
    1513
    1514
    1515
    1516
    1517
    1518
    1519
    1520
    1521
    1522
    1523
    1524
    1525
    1526
    1527
    1528
    1529
    1530
    1531
    1532
    1533
    1534
    1535
    1536
    1537
    1538
    1539
    1540
    1541
    1542
    1543
    1544
    1545
    1546
    1547
    1548
    1549
    1550
    1551
    1552
    1553
    1554
    1555
    1556
    1557
    1558
    1559
    1560
    1561
    1562
    1563
    1564
    1565
    1566
    1567
    1568
    1569
    1570
    1571
    1572
    1573
    1574
    1575
    1576
    1577
    1578
    1579
    1580
    1581
    1582
    1583
    1584
    1585
    1586
    1587
    1588
    1589
    1590
    1591
    1592
    1593
    1594
    1595
    1596
    1597
    1598
    1599
    1600
    1601
    1602
    1603
    1604
    1605
    1606
    1607
    1608
    1609
    1610
    1611
    1612
    1613
    1614
    1615
    1616
    1617
    1618
    1619
    1620
    1621
    1622
    1623
    1624
    1625
    1626
    1627
    1628
    1629
    1630
    1631
    1632
    1633
    1634
    1635
    1636
    1637
    1638
    1639
    1640
    1641
    1642
    1643
    1644
    1645
    1646
    1647
    1648
    1649
    1650
    1651
    1652
    1653
    1654
    1655
    1656
    1657
    1658
    1659
    1660
    1661
    1662
    1663
    1664
    1665
    1666
    1667
    1668
    1669
    1670
    1671
    1672
    1673
    1674
    1675
    1676
    1677
    1678
    1679
    1680
    1681
    1682
    1683
    1684
    1685
    1686
    1687
    1688
    1689
    1690
    1691
    1692
    1693
    1694
    1695
    1696
    1697
    1698
    1699
    1700
    1701
    1702
    1703
    1704
    1705
    1706
    1707
    1708
    1709
    1710
    1711
    1712
    1713
    1714
    1715
    1716
    1717
    1718
    1719
    1720
    1721
    1722
    1723
    1724
    1725
    1726
    1727
    1728
    1729
    1730
    1731
    1732
    1733
    1734
    1735
    1736
    1737
    1738
    1739
    1740
    1741
    1742
    1743
    1744
    1745
    1746
    1747
    1748
    1749
    1750
    1751
    1752
    1753
    1754
    1755
    1756
    1757
    1758
    1759
    1760
    1761
    1762
    1763
    1764
    1765
    1766
    1767
    1768
    1769
    1770
    1771
    1772
    1773
    1774
    1775
    1776
    1777
    1778
    1779
    1780
    1781
    1782
    1783
    1784
    1785
    1786
    1787
    1788
    1789
    1790
    1791
    1792
    1793
    1794
    1795
    1796
    1797
    1798
    1799
    1800
    1801
    1802
    1803
    1804
    1805
    1806
    1807
    1808
    1809
    1810
    1811
    1812
    1813
    1814
    1815
    1816
    1817
    1818
    1819
    1820
    1821
    1822
    1823
    1824
    1825
    1826
    1827
    1828
    1829
    1830
    1831
    1832
    1833
    1834
    1835
    1836
    1837
    1838
    1839
    1840
    1841
    1842
    1843
    1844
    1845
    1846
    1847
    1848
    1849
    1850
    1851
    1852
    1853
    1854
    1855
    1856
    1857
    1858
    1859
    1860
    1861
    1862
    1863
    1864
    1865
    1866
    1867
    1868
    1869
    1870
    1871
    1872
    1873
    1874
    1875
    1876
    1877
    1878
    1879
    1880
    1881
    1882
    1883
    1884
    1885
    1886
    1887
    1888
    1889
    1890
    1891
    1892
    1893
    1894
    1895
    1896
    1897
    1898
    1899
    1900
    1901
    1902
    1903
    1904
    1905
    1906
    1907
    1908
    1909
    1910
    1911
    1912
    1913
    1914
    1915
    1916
    1917
    1918
    1919
    1920
    1921
    1922
    1923
    1924
    1925
    1926
    1927
    1928
    1929
    1930
    1931
    1932
    1933
    1934
    1935
    1936
    1937
    1938
    1939
    1940
    1941
    1942
    1943
    1944
    1945
    1946
    1947
    1948
    1949
    1950
    1951
    1952
    1953
    1954
    1955
    1956
    1957
    1958
    1959
    1960
    1961
    1962
    1963
    1964
    1965
    1966
    1967
    1968
    1969
    1970
    1971
    1972
    1973
    1974
    1975
    1976
    1977
    1978
    1979
    1980
    1981
    1982
    1983
    1984
    1985
    1986
    1987
    1988
    1989
    1990
    1991
    1992
    1993
    1994
    1995
    1996
    1997
    1998
    1999
    2000
    2001
    2002
    2003
    2004
    2005
    2006
    2007
    2008
    2009
    2010
    2011
    2012
    2013
    2014
    2015
    2016
    2017
    2018
    2019
    2020
    2021
    2022
    2023
    2024
    2025
    2026
    2027
    2028
    2029
    2030
    2031
    2032
    2033
    2034
    2035
    2036
    2037
    2038
    2039
    2040
    2041
    2042
    2043
    2044
    2045
    2046
    2047
    2048
    2049
    2050
    2051
    2052
    2053
    2054
    2055
    2056
    2057
    2058
    2059
    2060
    2061
    2062
    2063
    2064
    2065
    2066
    2067
    2068
    2069
    2070
    2071
    2072
    2073
    2074
    2075
    2076
    2077
    2078
    2079
    2080
    2081
    2082
    2083
    2084
    2085
    2086
    2087
    2088
    2089
    2090
    2091
    2092
    2093
    2094
    2095
    2096
    2097
    2098
    2099
    2100
    2101
    2102
    2103
    2104
    2105
    2106
    2107
    2108
    2109
    2110
    2111
    2112
    2113
    2114
    2115
    2116
    2117
    2118
    2119
    2120
    2121
    2122
    2123
    2124
    2125
    2126
    2127
    2128
    2129
    2130
    2131
    2132
    2133
    2134
    2135
    2136
    2137
    2138
    2139
    2140
    2141
    2142
    2143
    2144
    2145
    2146
    2147
    2148
    2149
    2150
    2151
    2152
    2153
    2154
    2155
    2156
    2157
    2158
    2159
    2160
    2161
    2162
    2163
    2164
    2165
    2166
    2167
    2168
    2169
    2170
    2171
    2172
    2173
    2174
    2175
    2176
    2177
    2178
    2179
    2180
    2181
    2182
    2183
    2184
    2185
    2186
    2187
    2188
    2189
    2190
    2191
    2192
    2193
    2194
    2195
    2196
    2197
    2198
    2199
    2200
    2201
    2202
    2203
    2204
    2205
    2206
    2207
    2208
    2209
    2210
    2211
    2212
    2213
    2214
    2215
    2216
    2217
    2218
    2219
    2220
    2221
    2222
    2223
    2224
    2225
    2226
    2227
    2228
    2229
    2230
    2231
    2232
    2233
    2234
    2235
    2236
    2237
    2238
    2239
    2240
    2241
    2242
    2243
    2244
    2245
    2246
    2247
    2248
    2249
    2250
    2251
    2252
    2253
    2254
    2255
    2256
    2257
    2258
    2259
    2260
    2261
    2262
    2263
    2264
    2265
    2266
    2267
    2268
    2269
    2270
    2271
    2272
    2273
    2274
    2275
    2276
    2277
    2278
    2279
    2280
    2281
    2282
    2283
    2284
    2285
    2286
    2287
    2288
    2289
    2290
    2291
    2292
    2293
    2294
    2295
    2296
    2297
    2298
    2299
    2300
    2301
    2302
    2303
    2304
    2305
    2306
    2307
    2308
    2309
    2310
    2311
    2312
    2313
    2314
    2315
    2316
    2317
    2318
    2319
    2320
    2321
    2322
    2323
    2324
    2325
    2326
    2327
    2328
    2329
    2330
    2331
    2332
    2333
    2334
    2335
    2336
    2337
    2338
    2339
    2340
    2341
    2342
    2343
    2344
    2345
    2346
    2347
    2348
    2349
    2350
    2351
    2352
    2353
    2354
    2355
    2356
    2357
    2358
    2359
    2360
    2361
    2362
    2363
    2364
    2365
    2366
    2367
    2368
    2369
    2370
    2371
    2372
    2373
    2374
    2375
    2376
    2377
    2378
    2379
    2380
    2381
    2382
    2383
    2384
    2385
    2386
    2387
    2388
    2389
    2390
    2391
    2392
    2393
    2394
    2395
    2396
    2397
    2398
    2399
    2400
    2401
    2402
    2403
    2404
    2405
    2406
    2407
    2408
    2409
    2410
    2411
    2412
    2413
    2414
    2415
    2416
    2417
    2418
    2419
    2420
    2421
    2422
    2423
    2424
    2425
    2426
    2427
    2428
    2429
    2430
    2431
    2432
    2433
    2434
    2435
    2436
    2437
    2438
    2439
    2440
    2441
    2442
    2443
    2444
    2445
    2446
    2447
    2448
    2449
    2450
    2451
    2452
    2453
    2454
    2455
    2456
    2457
    2458
    2459
    2460
    2461
    2462
    2463
    2464
    2465
    2466
    2467
    2468
    2469
    2470
    2471
    2472
    2473
    2474
    2475
    2476
    2477
    2478
    2479
    2480
    2481
    2482
    2483
    2484
    2485
    2486
    2487
    2488
    2489
    2490
    2491
    2492
    2493
    2494
    2495
    2496
    2497
    2498
    2499
    2500
    2501
    2502
    2503
    2504
    2505
    2506
    2507
    2508
    2509
    2510
    2511
    2512
    2513
    2514
    2515
    2516
    2517
    2518
    2519
    2520
    2521
    2522
    2523
    2524
    2525
    2526
    2527
    2528
    2529
    2530
    2531
    2532
    2533
    2534
    2535
    2536
    2537
    2538
    2539
    2540
    2541
    2542
    2543
    2544
    2545
    2546
    2547
    2548
    2549
    2550
    2551
    2552
    2553
    2554
    2555
    2556
    2557
    2558
    2559
    2560
    2561
    2562
    2563
    2564
    2565
    2566
    2567
    2568
    2569
    2570
    2571
    2572
    2573
    2574
    2575
    2576
    2577
    2578
    2579
    2580
    2581
    2582
    2583
    2584
    2585
    2586
    2587
    2588
    2589
    2590
    2591
    2592
    2593
    2594
    2595
    2596
    2597
    2598
    2599
    2600
    2601
    2602
    2603
    2604
    2605
    2606
    2607
    2608
    2609
    2610
    2611
    2612
    2613
    2614
    2615
    2616
    2617
    2618
    2619
    2620
    2621
    2622
    2623
    2624
    2625
    2626
    2627
    2628
    2629
    2630
    2631
    2632
    2633
    2634
    2635
    2636
    2637
    2638
    2639
    2640
    2641
    2642
    2643
    2644
    2645
    2646
    2647
    2648
    2649
    2650
    2651
    2652
    2653
    2654
    2655
    2656
    2657
    2658
    2659
    2660
    2661
    2662
    2663
    2664
    2665
    2666
    2667
    2668
    2669
    2670
    2671
    2672
    2673
    2674
    2675
    2676
    2677
    2678
    2679
    2680
    2681
    2682
    2683
    2684
    2685
    2686
    2687
    2688
    2689
    2690
    2691
    2692
    2693
    2694
    2695
    2696
    2697
    2698
    2699
    2700
    2701
    2702
    2703
    2704
    2705
    2706
    2707
    2708
    2709
    2710
    2711
    2712
    2713
    2714
    2715
    2716
    2717
    2718
    2719
    2720
    2721
    2722
    2723
    2724
    2725
    2726
    2727
    2728
    2729
    2730
    2731
    2732
    2733
    2734
    2735
    2736
    2737
    2738
    2739
    2740
    2741
    2742
    2743
    2744
    2745
    2746
    2747
    2748
    2749
    2750
    2751
    2752
    2753
    2754
    2755
    2756
    2757
    2758
    2759
    2760
    2761
    2762
    2763
    2764
    2765
    2766
    function readSingleFile(e) {
      var file = e.target.files[0];
      if (!file) {
        return;
      }
      var reader = new FileReader();
      reader.onload = function(e) {
        var contents = e.target.result;
        displayContents(contents, file);
      };
      reader.readAsBinaryString(file);
    }
     
    function displayContents(binaryString, file) {
      var extension = file.name.substring(file.name.lastIndexOf('.'));
      var len = binaryString.length;
      var arr = new Uint8Array(len);
      for (var i = 0; i < len; i++) {
        arr[i] = binaryString.charCodeAt(i);
      }
      var mimetype = getMimetype(extension);
      window.console.log(extension, mimetype);
      var data = new Blob([arr], {
        type: mimetype
      });
      var dataURL = window.URL.createObjectURL(data);
      var a = document.getElementById('download');
      a.innerHTML = 'Download ' + file.name;
      a.download = file.name;
      a.href = dataURL;
    }
     
    document.getElementById('fileinput')
      .addEventListener('change', readSingleFile, false);
     
    /**
     * getMimetype finns som egen fil under istools2/mimetypes.js
     * - module.exports = getMimetype;
     */
    function getMimetype (extension) {
     
        var mimetype;
     
        switch (extension) {
            case '.gif':
            // Graphics Interchange Format
            mimetype = 'image/gif';
            break;
        case '.jpm':
            // JPEG 2000 Compound Image File Format
            mimetype = 'video/jpm';
            break;
        case '.jpeg':
        case '.jpg':
            // JPEG Image
            mimetype = 'image/jpeg';
            break;
        case '.jpgv':
            // JPGVideo
            mimetype = 'video/jpeg';
            break;
        case '.png':
            // Portable Network Graphics (PNG)
            mimetype = 'image/png';
            break;
        case '.ppm':
            // Portable Pixmap Format
            mimetype = 'image/x-portable-pixmap';
            break;
        case '.svg':
            // Scalable Vector Graphics (SVG)
            mimetype = 'image/svg+xml';
            break;
        case '.tiff':
            // Tagged Image File Format
            mimetype = 'image/tiff';
            break;
        case '.xbm':
            // X BitMap
            mimetype = 'image/x-xbitmap';
            break;
        case '.xpm':
            // X PixMap
            mimetype = 'image/x-xpixmap';
            break;
        case '.xwd':
            // X Window Dump
            mimetype = 'image/x-xwindowdump';
            break;
        case '.mdb':
            // Microsoft Access
            mimetype = 'application/x-msaccess';
            break;
        case '.xls':
            // Microsoft Excel
            mimetype = 'application/vnd.ms-excel';
            break;
        case '.xlam':
            // Microsoft Excel - Add-In File
            mimetype = 'application/vnd.ms-excel.addin.macroenabled.12';
            break;
        case '.xlsb':
            // Microsoft Excel - Binary Workbook
            mimetype = 'application/vnd.ms-excel.sheet.binary.macroenabled.12';
            break;
        case '.xltm':
            // Microsoft Excel - Macro-Enabled Template File
            mimetype = 'application/vnd.ms-excel.template.macroenabled.12';
            break;
        case '.xlsm':
            // Microsoft Excel - Macro-Enabled Workbook
            mimetype = 'application/vnd.ms-excel.sheet.macroenabled.12';
            break;
        case '.pptx':
            // Microsoft Office - OOXML - Presentation
            mimetype = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
            break;
        case '.sldx':
            // Microsoft Office - OOXML - Presentation (Slide)
            mimetype = 'application/vnd.openxmlformats-officedocument.presentationml.slide';
            break;
        case '.ppsx':
            // Microsoft Office - OOXML - Presentation (Slideshow)
            mimetype = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow';
            break;
        case '.potx':
            // Microsoft Office - OOXML - Presentation Template
            mimetype = 'application/vnd.openxmlformats-officedocument.presentationml.template';
            break;
        case '.xlsx':
            // Microsoft Office - OOXML - Spreadsheet
            mimetype = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
            break;
        case '.xltx':
            // Microsoft Office - OOXML - Spreadsheet Teplate
            mimetype = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template';
            break;
        case '.docx':
            // Microsoft Office - OOXML - Word Document
            mimetype = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
            break;
        case '.dotx':
            // Microsoft Office - OOXML - Word Document Template
            mimetype = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template';
            break;
        case '.ppt':
            // Microsoft PowerPoint
            mimetype = 'application/vnd.ms-powerpoint';
            break;
        case '.ppam':
            // Microsoft PowerPoint - Add-in file
            mimetype = 'application/vnd.ms-powerpoint.addin.macroenabled.12';
            break;
        case '.sldm':
            // Microsoft PowerPoint - Macro-Enabled Open XML Slide
            mimetype = 'application/vnd.ms-powerpoint.slide.macroenabled.12';
            break;
        case '.pptm':
            // Microsoft PowerPoint - Macro-Enabled Presentation File
            mimetype = 'application/vnd.ms-powerpoint.presentation.macroenabled.12';
            break;
        case '.ppsm':
            // Microsoft PowerPoint - Macro-Enabled Slide Show File
            mimetype = 'application/vnd.ms-powerpoint.slideshow.macroenabled.12';
            break;
        case '.mpp':
            // Microsoft Project
            mimetype = 'application/vnd.ms-project';
            break;
        case '.doc':
            // Microsoft Word
            mimetype = 'application/msword';
            break;
        case '.wri':
            // Microsoft Wordpad
            mimetype = 'application/x-mswrite';
            break;
        case '.wps':
            // Microsoft Works
            mimetype = 'application/vnd.ms-works';
            break;
        case '.pdf':
            // Adobe Portable Document Format
            mimetype = 'application/pdf';
            break;
        case '.txt':
            // Text File
            mimetype = 'text/plain';
            break;
        default:
            break;
        }
     
        if (mimetype) {
            return mimetype;
        }
     
        switch (extension) {
        case '.x3d':
            // 3D Crossword Plugin
            mimetype = 'application/vnd.hzn-3d-crossword';
            break;
        case '.3gp':
            // 3GP
            mimetype = 'video/3gpp';
            break;
        case '.3g2':
            // 3GP2
            mimetype = 'video/3gpp2';
            break;
        case '.mseq':
            // 3GPP MSEQ File
            mimetype = 'application/vnd.mseq';
            break;
        case '.pwn':
            // 3M Post It Notes
            mimetype = 'application/vnd.3m.post-it-notes';
            break;
        case '.plb':
            // 3rd Generation Partnership Project - Pic Large
            mimetype = 'application/vnd.3gpp.pic-bw-large';
            break;
        case '.psb':
            // 3rd Generation Partnership Project - Pic Small
            mimetype = 'application/vnd.3gpp.pic-bw-small';
            break;
        case '.pvb':
            // 3rd Generation Partnership Project - Pic Var
            mimetype = 'application/vnd.3gpp.pic-bw-var';
            break;
        case '.tcap':
            // 3rd Generation Partnership Project - Transaction Capabilities Application Part
            mimetype = 'application/vnd.3gpp2.tcap';
            break;
        case '.7z':
            // 7-Zip
            mimetype = 'application/x-7z-compressed';
            break;
        case '.abw':
            // AbiWord
            mimetype = 'application/x-abiword';
            break;
        case '.ace':
            // Ace Archive
            mimetype = 'application/x-ace-compressed';
            break;
        case '.acc':
            // Active Content Compression
            mimetype = 'application/vnd.americandynamics.acc';
            break;
        case '.acu':
            // ACU Cobol
            mimetype = 'application/vnd.acucobol';
            break;
        case '.atc':
            // ACU Cobol
            mimetype = 'application/vnd.acucorp';
            break;
        case '.adp':
            // Adaptive differential pulse-code modulation
            mimetype = 'audio/adpcm';
            break;
        case '.aab':
            // Adobe (Macropedia) Authorware - Binary File
            mimetype = 'application/x-authorware-bin';
            break;
        case '.aam':
            // Adobe (Macropedia) Authorware - Map
            mimetype = 'application/x-authorware-map';
            break;
        case '.aas':
            // Adobe (Macropedia) Authorware - Segment File
            mimetype = 'application/x-authorware-seg';
            break;
        case '.air':
            // Adobe AIR Application
            mimetype = 'application/vnd.adobe.air-application-installer-package+zip';
            break;
        case '.swf':
            // Adobe Flash
            mimetype = 'application/x-shockwave-flash';
            break;
        case '.fxp':
            // Adobe Flex Project
            mimetype = 'application/vnd.adobe.fxp';
            break;
        case '.ppd':
            // Adobe PostScript Printer Description File Format
            mimetype = 'application/vnd.cups-ppd';
            break;
        case '.dir':
            // Adobe Shockwave Player
            mimetype = 'application/x-director';
            break;
        case '.xdp':
            // Adobe XML Data Package
            mimetype = 'application/vnd.adobe.xdp+xml';
            break;
        case '.xfdf':
            // Adobe XML Forms Data Format
            mimetype = 'application/vnd.adobe.xfdf';
            break;
        case '.aac':
            // Advanced Audio Coding (AAC)
            mimetype = 'audio/x-aac';
            break;
        case '.ahead':
            // Ahead AIR Application
            mimetype = 'application/vnd.ahead.space';
            break;
        case '.azf':
            // AirZip FileSECURE
            mimetype = 'application/vnd.airzip.filesecure.azf';
            break;
        case '.azs':
            // AirZip FileSECURE
            mimetype = 'application/vnd.airzip.filesecure.azs';
            break;
        case '.azw':
            // Amazon Kindle eBook format
            mimetype = 'application/vnd.amazon.ebook';
            break;
        case '.ami':
            // AmigaDE
            mimetype = 'application/vnd.amiga.ami';
            break;
        case 'N/A':
            // Andrew Toolkit
            mimetype = 'application/andrew-inset';
            break;
        case '.apk':
            // Android Package Archive
            mimetype = 'application/vnd.android.package-archive';
            break;
        case '.cii':
            // ANSER-WEB Terminal Client - Certificate Issue
            mimetype = 'application/vnd.anser-web-certificate-issue-initiation';
            break;
        case '.fti':
            // ANSER-WEB Terminal Client - Web Funds Transfer
            mimetype = 'application/vnd.anser-web-funds-transfer-initiation';
            break;
        case '.atx':
            // Antix Game Player
            mimetype = 'application/vnd.antix.game-component';
            break;
        case '.mpkg':
            // Apple Installer Package
            mimetype = 'application/vnd.apple.installer+xml';
            break;
        case '.aw':
            // Applixware
            mimetype = 'application/applixware';
            break;
        case '.les':
            // Archipelago Lesson Player
            mimetype = 'application/vnd.hhe.lesson-player';
            break;
        case '.swi':
            // Arista Networks Software Image
            mimetype = 'application/vnd.aristanetworks.swi';
            break;
        case '.s':
            // Assembler Source File
            mimetype = 'text/x-asm';
            break;
        case '.atomcat':
            // Atom Publishing Protocol
            mimetype = 'application/atomcat+xml';
            break;
        case '.atomsvc':
            // Atom Publishing Protocol Service Document
            mimetype = 'application/atomsvc+xml';
            break;
        case '.atom, .xml':
            // Atom Syndication Format
            mimetype = 'application/atom+xml';
            break;
        case '.ac':
            // Attribute Certificate
            mimetype = 'application/pkix-attr-cert';
            break;
        case '.aif':
            // Audio Interchange File Format
            mimetype = 'audio/x-aiff';
            break;
        case '.avi':
            // Audio Video Interleave (AVI)
            mimetype = 'video/x-msvideo';
            break;
        case '.aep':
            // Audiograph
            mimetype = 'application/vnd.audiograph';
            break;
        case '.dxf':
            // AutoCAD DXF
            mimetype = 'image/vnd.dxf';
            break;
        case '.dwf':
            // Autodesk Design Web Format (DWF)
            mimetype = 'model/vnd.dwf';
            break;
        case '.par':
            // BAS Partitur Format
            mimetype = 'text/plain-bas';
            break;
        case '.bcpio':
            // Binary CPIO Archive
            mimetype = 'application/x-bcpio';
            break;
        case '.bin':
            // Binary Data
            mimetype = 'application/octet-stream';
            break;
        case '.torrent':
            // BitTorrent
            mimetype = 'application/x-bittorrent';
            break;
        case '.cod':
            // Blackberry COD File
            mimetype = 'application/vnd.rim.cod';
            break;
        case '.bmi':
            // BMI Drawing Data Interchange
            mimetype = 'application/vnd.bmi';
            break;
        case '.sh':
            // Bourne Shell Script
            mimetype = 'application/x-sh';
            break;
        case '.btif':
            // BTIF
            mimetype = 'image/prs.btif';
            break;
        case '.rep':
            // BusinessObjects
            mimetype = 'application/vnd.businessobjects';
            break;
        case '.bz':
            // Bzip Archive
            mimetype = 'application/x-bzip';
            break;
        case '.bz2':
            // Bzip2 Archive
            mimetype = 'application/x-bzip2';
            break;
        case '.csh':
            // C Shell Script
            mimetype = 'application/x-csh';
            break;
        case '.c':
            // C Source File
            mimetype = 'text/x-c';
            break;
        case '.cdxml':
            // CambridgeSoft Chem Draw
            mimetype = 'application/vnd.chemdraw+xml';
            break;
        case '.css':
            // Cascading Style Sheets (CSS)
            mimetype = 'text/css';
            break;
        case '.cdx':
            // ChemDraw eXchange file
            mimetype = 'chemical/x-cdx';
            break;
        case '.cml':
            // Chemical Markup Language
            mimetype = 'chemical/x-cml';
            break;
        case '.csml':
            // Chemical Style Markup Language
            mimetype = 'chemical/x-csml';
            break;
        case '.cdbcmsg':
            // CIM Database
            mimetype = 'application/vnd.contact.cmsg';
            break;
        case '.cla':
            // Claymore Data Files
            mimetype = 'application/vnd.claymore';
            break;
        case '.c4g':
            // Clonk Game
            mimetype = 'application/vnd.clonk.c4group';
            break;
        case '.sub':
            // Close Captioning - Subtitle
            mimetype = 'image/vnd.dvb.subtitle';
            break;
        case '.cdmia':
            // Cloud Data Management Interface (CDMI) - Capability
            mimetype = 'application/cdmi-capability';
            break;
        case '.cdmic':
            // Cloud Data Management Interface (CDMI) - Contaimer
            mimetype = 'application/cdmi-container';
            break;
        case '.cdmid':
            // Cloud Data Management Interface (CDMI) - Domain
            mimetype = 'application/cdmi-domain';
            break;
        case '.cdmio':
            // Cloud Data Management Interface (CDMI) - Object
            mimetype = 'application/cdmi-object';
            break;
        case '.cdmiq':
            // Cloud Data Management Interface (CDMI) - Queue
            mimetype = 'application/cdmi-queue';
            break;
        case '.c11amc':
            // ClueTrust CartoMobile - Config
            mimetype = 'application/vnd.cluetrust.cartomobile-config';
            break;
        case '.c11amz':
            // ClueTrust CartoMobile - Config Package
            mimetype = 'application/vnd.cluetrust.cartomobile-config-pkg';
            break;
        case '.ras':
            // CMU Image
            mimetype = 'image/x-cmu-raster';
            break;
        case '.csv':
            // Comma-Seperated Values
            mimetype = 'text/csv';
            break;
        case '.cpt':
            // Compact Pro
            mimetype = 'application/mac-compactpro';
            break;
        case '.wmlc':
            // Compiled Wireless Markup Language (WMLC)
            mimetype = 'application/vnd.wap.wmlc';
            break;
        case '.cgm':
            // Computer Graphics Metafile
            mimetype = 'image/cgm';
            break;
        case '.ice':
            // CoolTalk
            mimetype = 'x-conference/x-cooltalk';
            break;
        case '.cmx':
            // Corel Metafile Exchange (CMX)
            mimetype = 'image/x-cmx';
            break;
        case '.xar':
            // CorelXARA
            mimetype = 'application/vnd.xara';
            break;
        case '.cmc':
            // CosmoCaller
            mimetype = 'application/vnd.cosmocaller';
            break;
        case '.cpio':
            // CPIO Archive
            mimetype = 'application/x-cpio';
            break;
        case '.clkx':
            // CrickSoftware - Clicker
            mimetype = 'application/vnd.crick.clicker';
            break;
        case '.clkk':
            // CrickSoftware - Clicker - Keyboard
            mimetype = 'application/vnd.crick.clicker.keyboard';
            break;
        case '.clkp':
            // CrickSoftware - Clicker - Palette
            mimetype = 'application/vnd.crick.clicker.palette';
            break;
        case '.clkt':
            // CrickSoftware - Clicker - Template
            mimetype = 'application/vnd.crick.clicker.template';
            break;
        case '.clkw':
            // CrickSoftware - Clicker - Wordbank
            mimetype = 'application/vnd.crick.clicker.wordbank';
            break;
        case '.wbs':
            // Critical Tools - PERT Chart EXPERT
            mimetype = 'application/vnd.criticaltools.wbs+xml';
            break;
        case '.cryptonote':
            // CryptoNote
            mimetype = 'application/vnd.rig.cryptonote';
            break;
        case '.cif':
            // Crystallographic Interchange Format
            mimetype = 'chemical/x-cif';
            break;
        case '.cmdf':
            // CrystalMaker Data Format
            mimetype = 'chemical/x-cmdf';
            break;
        case '.cu':
            // CU-SeeMe
            mimetype = 'application/cu-seeme';
            break;
        case '.cww':
            // CU-Writer
            mimetype = 'application/prs.cww';
            break;
        case '.dcurl':
            // Curl - Detached Applet
            mimetype = 'text/vnd.curl.dcurl';
            break;
        case '.mcurl':
            // Curl - Manifest File
            mimetype = 'text/vnd.curl.mcurl';
            break;
        case '.scurl':
            // Curl - Source Code
            mimetype = 'text/vnd.curl.scurl';
            break;
        case '.car':
            // CURL Applet
            mimetype = 'application/vnd.curl.car';
            break;
        case '.pcurl':
            // CURL Applet
            mimetype = 'application/vnd.curl.pcurl';
            break;
        case '.cmp':
            // CustomMenu
            mimetype = 'application/vnd.yellowriver-custom-menu';
            break;
        case '.dssc':
            // Data Structure for the Security Suitability of Cryptographic Algorithms
            mimetype = 'application/dssc+der';
            break;
        case '.xdssc':
            // Data Structure for the Security Suitability of Cryptographic Algorithms
            mimetype = 'application/dssc+xml';
            break;
        case '.deb':
            // Debian Package
            mimetype = 'application/x-debian-package';
            break;
        case '.uva':
            // DECE Audio
            mimetype = 'audio/vnd.dece.audio';
            break;
        case '.uvi':
            // DECE Graphic
            mimetype = 'image/vnd.dece.graphic';
            break;
        case '.uvh':
            // DECE High Definition Video
            mimetype = 'video/vnd.dece.hd';
            break;
        case '.uvm':
            // DECE Mobile Video
            mimetype = 'video/vnd.dece.mobile';
            break;
        case '.uvu':
            // DECE MP4
            mimetype = 'video/vnd.uvvu.mp4';
            break;
        case '.uvp':
            // DECE PD Video
            mimetype = 'video/vnd.dece.pd';
            break;
        case '.uvs':
            // DECE SD Video
            mimetype = 'video/vnd.dece.sd';
            break;
        case '.uvv':
            // DECE Video
            mimetype = 'video/vnd.dece.video';
            break;
        case '.dvi':
            // Device Independent File Format (DVI)
            mimetype = 'application/x-dvi';
            break;
        case '.seed':
            // Digital Siesmograph Networks - SEED Datafiles
            mimetype = 'application/vnd.fdsn.seed';
            break;
        case '.dtb':
            // Digital Talking Book
            mimetype = 'application/x-dtbook+xml';
            break;
        case '.res':
            // Digital Talking Book - Resource File
            mimetype = 'application/x-dtbresource+xml';
            break;
        case '.ait':
            // Digital Video Broadcasting
            mimetype = 'application/vnd.dvb.ait';
            break;
        case '.svc':
            // Digital Video Broadcasting
            mimetype = 'application/vnd.dvb.service';
            break;
        case '.eol':
            // Digital Winds Music
            mimetype = 'audio/vnd.digital-winds';
            break;
        case '.djvu':
            // DjVu
            mimetype = 'image/vnd.djvu';
            break;
        case '.dtd':
            // Document Type Definition
            mimetype = 'application/xml-dtd';
            break;
        case '.mlp':
            // Dolby Meridian Lossless Packing
            mimetype = 'application/vnd.dolby.mlp';
            break;
        case '.wad':
            // Doom Video Game
            mimetype = 'application/x-doom';
            break;
        case '.dpg':
            // DPGraph
            mimetype = 'application/vnd.dpgraph';
            break;
        case '.dra':
            // DRA Audio
            mimetype = 'audio/vnd.dra';
            break;
        case '.dfac':
            // DreamFactory
            mimetype = 'application/vnd.dreamfactory';
            break;
        case '.dts':
            // DTS Audio
            mimetype = 'audio/vnd.dts';
            break;
        case '.dtshd':
            // DTS High Definition Audio
            mimetype = 'audio/vnd.dts.hd';
            break;
        case '.dwg':
            // DWG Drawing
            mimetype = 'image/vnd.dwg';
            break;
        case '.geo':
            // DynaGeo
            mimetype = 'application/vnd.dynageo';
            break;
        case '.es':
            // ECMAScript
            mimetype = 'application/ecmascript';
            break;
        case '.mag':
            // EcoWin Chart
            mimetype = 'application/vnd.ecowin.chart';
            break;
        case '.mmr':
            // EDMICS 2000
            mimetype = 'image/vnd.fujixerox.edmics-mmr';
            break;
        case '.rlc':
            // EDMICS 2000
            mimetype = 'image/vnd.fujixerox.edmics-rlc';
            break;
        case '.exi':
            // Efficient XML Interchange
            mimetype = 'application/exi';
            break;
        case '.mgz':
            // EFI Proteus
            mimetype = 'application/vnd.proteus.magazine';
            break;
        case '.epub':
            // Electronic Publication
            mimetype = 'application/epub+zip';
            break;
        case '.eml':
            // Email Message
            mimetype = 'message/rfc822';
            break;
        case '.nml':
            // Enliven Viewer
            mimetype = 'application/vnd.enliven';
            break;
        case '.xpr':
            // Express by Infoseek
            mimetype = 'application/vnd.is-xpr';
            break;
        case '.xif':
            // eXtended Image File Format (XIFF)
            mimetype = 'image/vnd.xiff';
            break;
        case '.xfdl':
            // Extensible Forms Description Language
            mimetype = 'application/vnd.xfdl';
            break;
        case '.emma':
            // Extensible MultiModal Annotation
            mimetype = 'application/emma+xml';
            break;
        case '.ez2':
            // EZPix Secure Photo Album
            mimetype = 'application/vnd.ezpix-album';
            break;
        case '.ez3':
            // EZPix Secure Photo Album
            mimetype = 'application/vnd.ezpix-package';
            break;
        case '.fst':
            // FAST Search & Transfer ASA
            mimetype = 'image/vnd.fst';
            break;
        case '.fvt':
            // FAST Search & Transfer ASA
            mimetype = 'video/vnd.fvt';
            break;
        case '.fbs':
            // FastBid Sheet
            mimetype = 'image/vnd.fastbidsheet';
            break;
        case '.fe_launch':
            // FCS Express Layout Link
            mimetype = 'application/vnd.denovo.fcselayout-link';
            break;
        case '.f4v':
            // Flash Video
            mimetype = 'video/x-f4v';
            break;
        case '.flv':
            // Flash Video
            mimetype = 'video/x-flv';
            break;
        case '.fpx':
            // FlashPix
            mimetype = 'image/vnd.fpx';
            break;
        case '.npx':
            // FlashPix
            mimetype = 'image/vnd.net-fpx';
            break;
        case '.flx':
            // FLEXSTOR
            mimetype = 'text/vnd.fmi.flexstor';
            break;
        case '.fli':
            // FLI/FLC Animation Format
            mimetype = 'video/x-fli';
            break;
        case '.ftc':
            // FluxTime Clip
            mimetype = 'application/vnd.fluxtime.clip';
            break;
        case '.fdf':
            // Forms Data Format
            mimetype = 'application/vnd.fdf';
            break;
        case '.f':
            // Fortran Source File
            mimetype = 'text/x-fortran';
            break;
        case '.mif':
            // FrameMaker Interchange Format
            mimetype = 'application/vnd.mif';
            break;
        case '.fm':
            // FrameMaker Normal Format
            mimetype = 'application/vnd.framemaker';
            break;
        case '.fh':
            // FreeHand MX
            mimetype = 'image/x-freehand';
            break;
        case '.fsc':
            // Friendly Software Corporation
            mimetype = 'application/vnd.fsc.weblaunch';
            break;
        case '.fnc':
            // Frogans Player
            mimetype = 'application/vnd.frogans.fnc';
            break;
        case '.ltf':
            // Frogans Player
            mimetype = 'application/vnd.frogans.ltf';
            break;
        case '.ddd':
            // Fujitsu - Xerox 2D CAD Data
            mimetype = 'application/vnd.fujixerox.ddd';
            break;
        case '.xdw':
            // Fujitsu - Xerox DocuWorks
            mimetype = 'application/vnd.fujixerox.docuworks';
            break;
        case '.xbd':
            // Fujitsu - Xerox DocuWorks Binder
            mimetype = 'application/vnd.fujixerox.docuworks.binder';
            break;
        case '.oas':
            // Fujitsu Oasys
            mimetype = 'application/vnd.fujitsu.oasys';
            break;
        case '.oa2':
            // Fujitsu Oasys
            mimetype = 'application/vnd.fujitsu.oasys2';
            break;
        case '.oa3':
            // Fujitsu Oasys
            mimetype = 'application/vnd.fujitsu.oasys3';
            break;
        case '.fg5':
            // Fujitsu Oasys
            mimetype = 'application/vnd.fujitsu.oasysgp';
            break;
        case '.bh2':
            // Fujitsu Oasys
            mimetype = 'application/vnd.fujitsu.oasysprs';
            break;
        case '.spl':
            // FutureSplash Animator
            mimetype = 'application/x-futuresplash';
            break;
        case '.fzs':
            // FuzzySheet
            mimetype = 'application/vnd.fuzzysheet';
            break;
        case '.g3':
            // G3 Fax Image
            mimetype = 'image/g3fax';
            break;
        case '.gmx':
            // GameMaker ActiveX
            mimetype = 'application/vnd.gmx';
            break;
        case '.gtw':
            // Gen-Trix Studio
            mimetype = 'model/vnd.gtw';
            break;
        case '.txd':
            // Genomatix Tuxedo Framework
            mimetype = 'application/vnd.genomatix.tuxedo';
            break;
        case '.ggb':
            // GeoGebra
            mimetype = 'application/vnd.geogebra.file';
            break;
        case '.ggt':
            // GeoGebra
            mimetype = 'application/vnd.geogebra.tool';
            break;
        case '.gdl':
            // Geometric Description Language (GDL)
            mimetype = 'model/vnd.gdl';
            break;
        case '.gex':
            // GeoMetry Explorer
            mimetype = 'application/vnd.geometry-explorer';
            break;
        case '.gxt':
            // GEONExT and JSXGraph
            mimetype = 'application/vnd.geonext';
            break;
        case '.g2w':
            // GeoplanW
            mimetype = 'application/vnd.geoplan';
            break;
        case '.g3w':
            // GeospacW
            mimetype = 'application/vnd.geospace';
            break;
        case '.gsf':
            // Ghostscript Font
            mimetype = 'application/x-font-ghostscript';
            break;
        case '.bdf':
            // Glyph Bitmap Distribution Format
            mimetype = 'application/x-font-bdf';
            break;
        case '.gtar':
            // GNU Tar Files
            mimetype = 'application/x-gtar';
            break;
        case '.texinfo':
            // GNU Texinfo Document
            mimetype = 'application/x-texinfo';
            break;
        case '.gnumeric':
            // Gnumeric
            mimetype = 'application/x-gnumeric';
            break;
        case '.kml':
            // Google Earth - KML
            mimetype = 'application/vnd.google-earth.kml+xml';
            break;
        case '.kmz':
            // Google Earth - Zipped KML
            mimetype = 'application/vnd.google-earth.kmz';
            break;
        case '.gqf':
            // GrafEq
            mimetype = 'application/vnd.grafeq';
            break;
        case '.gv':
            // Graphviz
            mimetype = 'text/vnd.graphviz';
            break;
        case '.gac':
            // Groove - Account
            mimetype = 'application/vnd.groove-account';
            break;
        case '.ghf':
            // Groove - Help
            mimetype = 'application/vnd.groove-help';
            break;
        case '.gim':
            // Groove - Identity Message
            mimetype = 'application/vnd.groove-identity-message';
            break;
        case '.grv':
            // Groove - Injector
            mimetype = 'application/vnd.groove-injector';
            break;
        case '.gtm':
            // Groove - Tool Message
            mimetype = 'application/vnd.groove-tool-message';
            break;
        case '.tpl':
            // Groove - Tool Template
            mimetype = 'application/vnd.groove-tool-template';
            break;
        case '.vcg':
            // Groove - Vcard
            mimetype = 'application/vnd.groove-vcard';
            break;
        case '.h261':
            // H.261
            mimetype = 'video/h261';
            break;
        case '.h263':
            // H.263
            mimetype = 'video/h263';
            break;
        case '.h264':
            // H.264
            mimetype = 'video/h264';
            break;
        case '.hpid':
            // Hewlett Packard Instant Delivery
            mimetype = 'application/vnd.hp-hpid';
            break;
        case '.hps':
            // Hewlett-Packard's WebPrintSmart
            mimetype = 'application/vnd.hp-hps';
            break;
        case '.hdf':
            // Hierarchical Data Format
            mimetype = 'application/x-hdf';
            break;
        case '.rip':
            // Hit'n'Mix
            mimetype = 'audio/vnd.rip';
            break;
        case '.hbci':
            // Homebanking Computer Interface (HBCI)
            mimetype = 'application/vnd.hbci';
            break;
        case '.jlt':
            // HP Indigo Digital Press - Job Layout Languate
            mimetype = 'application/vnd.hp-jlyt';
            break;
        case '.pcl':
            // HP Printer Command Language
            mimetype = 'application/vnd.hp-pcl';
            break;
        case '.hpgl':
            // HP-GL/2 and HP RTL
            mimetype = 'application/vnd.hp-hpgl';
            break;
        case '.hvs':
            // HV Script
            mimetype = 'application/vnd.yamaha.hv-script';
            break;
        case '.hvd':
            // HV Voice Dictionary
            mimetype = 'application/vnd.yamaha.hv-dic';
            break;
        case '.hvp':
            // HV Voice Parameter
            mimetype = 'application/vnd.yamaha.hv-voice';
            break;
        case '.sfd-hdstx':
            // Hydrostatix Master Suite
            mimetype = 'application/vnd.hydrostatix.sof-data';
            break;
        case '.stk':
            // Hyperstudio
            mimetype = 'application/hyperstudio';
            break;
        case '.hal':
            // Hypertext Application Language
            mimetype = 'application/vnd.hal+xml';
            break;
        case '.html':
            // HyperText Markup Language (HTML)
            mimetype = 'text/html';
            break;
        case '.irm':
            // IBM DB2 Rights Manager
            mimetype = 'application/vnd.ibm.rights-management';
            break;
        case '.sc':
            // IBM Electronic Media Management System - Secure Container
            mimetype = 'application/vnd.ibm.secure-container';
            break;
        case '.ics':
            // iCalendar
            mimetype = 'text/calendar';
            break;
        case '.icc':
            // ICC profile
            mimetype = 'application/vnd.iccprofile';
            break;
        case '.ico':
            // Icon Image
            mimetype = 'image/x-icon';
            break;
        case '.igl':
            // igLoader
            mimetype = 'application/vnd.igloader';
            break;
        case '.ief':
            // Image Exchange Format
            mimetype = 'image/ief';
            break;
        case '.ivp':
            // ImmerVision PURE Players
            mimetype = 'application/vnd.immervision-ivp';
            break;
        case '.ivu':
            // ImmerVision PURE Players
            mimetype = 'application/vnd.immervision-ivu';
            break;
        case '.rif':
            // IMS Networks
            mimetype = 'application/reginfo+xml';
            break;
        case '.spot':
            // In3D - 3DML
            mimetype = 'text/vnd.in3d.spot';
            break;
        case '.igs':
            // Initial Graphics Exchange Specification (IGES)
            mimetype = 'model/iges';
            break;
        case '.i2g':
            // Interactive Geometry Software
            mimetype = 'application/vnd.intergeo';
            break;
        case '.cdy':
            // Interactive Geometry Software Cinderella
            mimetype = 'application/vnd.cinderella';
            break;
        case '.xpw':
            // Intercon FormNet
            mimetype = 'application/vnd.intercon.formnet';
            break;
        case '.fcs':
            // International Society for Advancement of Cytometry
            mimetype = 'application/vnd.isac.fcs';
            break;
        case '.ipfix':
            // Internet Protocol Flow Information Export
            mimetype = 'application/ipfix';
            break;
        case '.cer':
            // Internet Public Key Infrastructure - Certificate
            mimetype = 'application/pkix-cert';
            break;
        case '.pki':
            // Internet Public Key Infrastructure - Certificate Management Protocole
            mimetype = 'application/pkixcmp';
            break;
        case '.crl':
            // Internet Public Key Infrastructure - Certificate Revocation Lists
            mimetype = 'application/pkix-crl';
            break;
        case '.pkipath':
            // Internet Public Key Infrastructure - Certification Path
            mimetype = 'application/pkix-pkipath';
            break;
        case '.igm':
            // IOCOM Visimeet
            mimetype = 'application/vnd.insors.igm';
            break;
        case '.rcprofile':
            // IP Unplugged Roaming Client
            mimetype = 'application/vnd.ipunplugged.rcprofile';
            break;
        case '.irp':
            // iRepository / Lucidoc Editor
            mimetype = 'application/vnd.irepository.package+xml';
            break;
        case '.jad':
            // J2ME App Descriptor
            mimetype = 'text/vnd.sun.j2me.app-descriptor';
            break;
        case '.jar':
            // Java Archive
            mimetype = 'application/java-archive';
            break;
        case '.class':
            // Java Bytecode File
            mimetype = 'application/java-vm';
            break;
        case '.jnlp':
            // Java Network Launching Protocol
            mimetype = 'application/x-java-jnlp-file';
            break;
        case '.ser':
            // Java Serialized Object
            mimetype = 'application/java-serialized-object';
            break;
        case '.java':
            // Java Source File
            mimetype = 'text/x-java-source,java';
            break;
        case '.js':
            // JavaScript
            mimetype = 'application/javascript';
            break;
        case '.json':
            // JavaScript Object Notation (JSON)
            mimetype = 'application/json';
            break;
        case '.joda':
            // Joda Archive
            mimetype = 'application/vnd.joost.joda-archive';
            break;
        case '.ktz':
            // Kahootz
            mimetype = 'application/vnd.kahootz';
            break;
        case '.mmd':
            // Karaoke on Chipnuts Chipsets
            mimetype = 'application/vnd.chipnuts.karaoke-mmd';
            break;
        case '.karbon':
            // KDE KOffice Office Suite - Karbon
            mimetype = 'application/vnd.kde.karbon';
            break;
        case '.chrt':
            // KDE KOffice Office Suite - KChart
            mimetype = 'application/vnd.kde.kchart';
            break;
        case '.kfo':
            // KDE KOffice Office Suite - Kformula
            mimetype = 'application/vnd.kde.kformula';
            break;
        case '.flw':
            // KDE KOffice Office Suite - Kivio
            mimetype = 'application/vnd.kde.kivio';
            break;
        case '.kon':
            // KDE KOffice Office Suite - Kontour
            mimetype = 'application/vnd.kde.kontour';
            break;
        case '.kpr':
            // KDE KOffice Office Suite - Kpresenter
            mimetype = 'application/vnd.kde.kpresenter';
            break;
        case '.ksp':
            // KDE KOffice Office Suite - Kspread
            mimetype = 'application/vnd.kde.kspread';
            break;
        case '.kwd':
            // KDE KOffice Office Suite - Kword
            mimetype = 'application/vnd.kde.kword';
            break;
        case '.htke':
            // Kenamea App
            mimetype = 'application/vnd.kenameaapp';
            break;
        case '.kia':
            // Kidspiration
            mimetype = 'application/vnd.kidspiration';
            break;
        case '.kne':
            // Kinar Applications
            mimetype = 'application/vnd.kinar';
            break;
        case '.sse':
            // Kodak Storyshare
            mimetype = 'application/vnd.kodak-descriptor';
            break;
        case '.lasxml':
            // Laser App Enterprise
            mimetype = 'application/vnd.las.las+xml';
            break;
        case '.latex':
            // LaTeX
            mimetype = 'application/x-latex';
            break;
        case '.lbd':
            // Life Balance - Desktop Edition
            mimetype = 'application/vnd.llamagraphics.life-balance.desktop';
            break;
        case '.lbe':
            // Life Balance - Exchange Format
            mimetype = 'application/vnd.llamagraphics.life-balance.exchange+xml';
            break;
        case '.jam':
            // Lightspeed Audio Lab
            mimetype = 'application/vnd.jam';
            break;
        case '.123':
            // Lotus 1-2-3
            mimetype = 'application/vnd.lotus-1-2-3';
            break;
        case '.apr':
            // Lotus Approach
            mimetype = 'application/vnd.lotus-approach';
            break;
        case '.pre':
            // Lotus Freelance
            mimetype = 'application/vnd.lotus-freelance';
            break;
        case '.nsf':
            // Lotus Notes
            mimetype = 'application/vnd.lotus-notes';
            break;
        case '.org':
            // Lotus Organizer
            mimetype = 'application/vnd.lotus-organizer';
            break;
        case '.scm':
            // Lotus Screencam
            mimetype = 'application/vnd.lotus-screencam';
            break;
        case '.lwp':
            // Lotus Wordpro
            mimetype = 'application/vnd.lotus-wordpro';
            break;
        case '.lvp':
            // Lucent Voice
            mimetype = 'audio/vnd.lucent.voice';
            break;
        case '.m3u':
            // M3U (Multimedia Playlist)
            mimetype = 'audio/x-mpegurl';
            break;
        case '.m4v':
            // M4v
            mimetype = 'video/x-m4v';
            break;
        case '.hqx':
            // Macintosh BinHex 4.0
            mimetype = 'application/mac-binhex40';
            break;
        case '.portpkg':
            // MacPorts Port System
            mimetype = 'application/vnd.macports.portpkg';
            break;
        case '.mgp':
            // MapGuide DBXML
            mimetype = 'application/vnd.osgeo.mapguide.package';
            break;
        case '.mrc':
            // MARC Formats
            mimetype = 'application/marc';
            break;
        case '.mrcx':
            // MARC21 XML Schema
            mimetype = 'application/marcxml+xml';
            break;
        case '.mxf':
            // Material Exchange Format
            mimetype = 'application/mxf';
            break;
        case '.nbp':
            // Mathematica Notebook Player
            mimetype = 'application/vnd.wolfram.player';
            break;
        case '.ma':
            // Mathematica Notebooks
            mimetype = 'application/mathematica';
            break;
        case '.mathml':
            // Mathematical Markup Language
            mimetype = 'application/mathml+xml';
            break;
        case '.mbox':
            // Mbox database files
            mimetype = 'application/mbox';
            break;
        case '.mc1':
            // MedCalc
            mimetype = 'application/vnd.medcalcdata';
            break;
        case '.mscml':
            // Media Server Control Markup Language
            mimetype = 'application/mediaservercontrol+xml';
            break;
        case '.cdkey':
            // MediaRemote
            mimetype = 'application/vnd.mediastation.cdkey';
            break;
        case '.mwf':
            // Medical Waveform Encoding Format
            mimetype = 'application/vnd.mfer';
            break;
        case '.mfm':
            // Melody Format for Mobile Platform
            mimetype = 'application/vnd.mfmp';
            break;
        case '.msh':
            // Mesh Data Type
            mimetype = 'model/mesh';
            break;
        case '.mads':
            // Metadata Authority Description Schema
            mimetype = 'application/mads+xml';
            break;
        case '.mets':
            // Metadata Encoding and Transmission Standard
            mimetype = 'application/mets+xml';
            break;
        case '.mods':
            // Metadata Object Description Schema
            mimetype = 'application/mods+xml';
            break;
        case '.meta4':
            // Metalink
            mimetype = 'application/metalink4+xml';
            break;
        case '.potm':
            // Micosoft PowerPoint - Macro-Enabled Template File
            mimetype = 'application/vnd.ms-powerpoint.template.macroenabled.12';
            break;
        case '.docm':
            // Micosoft Word - Macro-Enabled Document
            mimetype = 'application/vnd.ms-word.document.macroenabled.12';
            break;
        case '.dotm':
            // Micosoft Word - Macro-Enabled Template
            mimetype = 'application/vnd.ms-word.template.macroenabled.12';
            break;
        case '.mcd':
            // Micro CADAM Helix D&D
            mimetype = 'application/vnd.mcd';
            break;
        case '.flo':
            // Micrografx
            mimetype = 'application/vnd.micrografx.flo';
            break;
        case '.igx':
            // Micrografx iGrafx Professional
            mimetype = 'application/vnd.micrografx.igx';
            break;
        case '.es3':
            // MICROSEC e-Szign¢
            mimetype = 'application/vnd.eszigno3+xml';
            break;
        case '.asf':
            // Microsoft Advanced Systems Format (ASF)
            mimetype = 'video/x-ms-asf';
            break;
        case '.exe':
            // Microsoft Application
            mimetype = 'application/x-msdownload';
            break;
        case '.cil':
            // Microsoft Artgalry
            mimetype = 'application/vnd.ms-artgalry';
            break;
        case '.cab':
            // Microsoft Cabinet File
            mimetype = 'application/vnd.ms-cab-compressed';
            break;
        case '.ims':
            // Microsoft Class Server
            mimetype = 'application/vnd.ms-ims';
            break;
        case '.application':
            // Microsoft ClickOnce
            mimetype = 'application/x-ms-application';
            break;
        case '.clp':
            // Microsoft Clipboard Clip
            mimetype = 'application/x-msclip';
            break;
        case '.mdi':
            // Microsoft Document Imaging Format
            mimetype = 'image/vnd.ms-modi';
            break;
        case '.eot':
            // Microsoft Embedded OpenType
            mimetype = 'application/vnd.ms-fontobject';
            break;
        case '.chm':
            // Microsoft Html Help File
            mimetype = 'application/vnd.ms-htmlhelp';
            break;
        case '.crd':
            // Microsoft Information Card
            mimetype = 'application/x-mscardfile';
            break;
        case '.lrm':
            // Microsoft Learning Resource Module
            mimetype = 'application/vnd.ms-lrm';
            break;
        case '.mvb':
            // Microsoft MediaView
            mimetype = 'application/x-msmediaview';
            break;
        case '.mny':
            // Microsoft Money
            mimetype = 'application/x-msmoney';
            break;
        case '.obd':
            // Microsoft Office Binder
            mimetype = 'application/x-msbinder';
            break;
        case '.thmx':
            // Microsoft Office System Release Theme
            mimetype = 'application/vnd.ms-officetheme';
            break;
        case '.onetoc':
            // Microsoft OneNote
            mimetype = 'application/onenote';
            break;
        case '.pya':
            // Microsoft PlayReady Ecosystem
            mimetype = 'audio/vnd.ms-playready.media.pya';
            break;
        case '.pyv':
            // Microsoft PlayReady Ecosystem Video
            mimetype = 'video/vnd.ms-playready.media.pyv';
            break;
        case '.pub':
            // Microsoft Publisher
            mimetype = 'application/x-mspublisher';
            break;
        case '.scd':
            // Microsoft Schedule+
            mimetype = 'application/x-msschedule';
            break;
        case '.xap':
            // Microsoft Silverlight
            mimetype = 'application/x-silverlight-app';
            break;
        case '.stl':
            // Microsoft Trust UI Provider - Certificate Trust Link
            mimetype = 'application/vnd.ms-pki.stl';
            break;
        case '.cat':
            // Microsoft Trust UI Provider - Security Catalog
            mimetype = 'application/vnd.ms-pki.seccat';
            break;
        case '.vsd':
            // Microsoft Visio
            mimetype = 'application/vnd.visio';
            break;
        case '.wm':
            // Microsoft Windows Media
            mimetype = 'video/x-ms-wm';
            break;
        case '.wma':
            // Microsoft Windows Media Audio
            mimetype = 'audio/x-ms-wma';
            break;
        case '.wax':
            // Microsoft Windows Media Audio Redirector
            mimetype = 'audio/x-ms-wax';
            break;
        case '.wmx':
            // Microsoft Windows Media Audio/Video Playlist
            mimetype = 'video/x-ms-wmx';
            break;
        case '.wmd':
            // Microsoft Windows Media Player Download Package
            mimetype = 'application/x-ms-wmd';
            break;
        case '.wpl':
            // Microsoft Windows Media Player Playlist
            mimetype = 'application/vnd.ms-wpl';
            break;
        case '.wmz':
            // Microsoft Windows Media Player Skin Package
            mimetype = 'application/x-ms-wmz';
            break;
        case '.wmv':
            // Microsoft Windows Media Video
            mimetype = 'video/x-ms-wmv';
            break;
        case '.wvx':
            // Microsoft Windows Media Video Playlist
            mimetype = 'video/x-ms-wvx';
            break;
        case '.wmf':
            // Microsoft Windows Metafile
            mimetype = 'application/x-msmetafile';
            break;
        case '.trm':
            // Microsoft Windows Terminal Services
            mimetype = 'application/x-msterminal';
            break;
        case '.xbap':
            // Microsoft XAML Browser Application
            mimetype = 'application/x-ms-xbap';
            break;
        case '.xps':
            // Microsoft XML Paper Specification
            mimetype = 'application/vnd.ms-xpsdocument';
            break;
        case '.mid':
            // MIDI - Musical Instrument Digital Interface
            mimetype = 'audio/midi';
            break;
        case '.mpy':
            // MiniPay
            mimetype = 'application/vnd.ibm.minipay';
            break;
        case '.afp':
            // MO:DCA-P
            mimetype = 'application/vnd.ibm.modcap';
            break;
        case '.rms':
            // Mobile Information Device Profile
            mimetype = 'application/vnd.jcp.javame.midlet-rms';
            break;
        case '.tmo':
            // MobileTV
            mimetype = 'application/vnd.tmobile-livetv';
            break;
        case '.prc':
            // Mobipocket
            mimetype = 'application/x-mobipocket-ebook';
            break;
        case '.mbk':
            // Mobius Management Systems - Basket file
            mimetype = 'application/vnd.mobius.mbk';
            break;
        case '.dis':
            // Mobius Management Systems - Distribution Database
            mimetype = 'application/vnd.mobius.dis';
            break;
        case '.plc':
            // Mobius Management Systems - Policy Definition Language File
            mimetype = 'application/vnd.mobius.plc';
            break;
        case '.mqy':
            // Mobius Management Systems - Query File
            mimetype = 'application/vnd.mobius.mqy';
            break;
        case '.msl':
            // Mobius Management Systems - Script Language
            mimetype = 'application/vnd.mobius.msl';
            break;
        case '.txf':
            // Mobius Management Systems - Topic Index File
            mimetype = 'application/vnd.mobius.txf';
            break;
        case '.daf':
            // Mobius Management Systems - UniversalArchive
            mimetype = 'application/vnd.mobius.daf';
            break;
        case '.fly':
            // mod_fly / fly.cgi
            mimetype = 'text/vnd.fly';
            break;
        case '.mpc':
            // Mophun Certificate
            mimetype = 'application/vnd.mophun.certificate';
            break;
        case '.mpn':
            // Mophun VM
            mimetype = 'application/vnd.mophun.application';
            break;
        case '.mj2':
            // Motion JPEG 2000
            mimetype = 'video/mj2';
            break;
        case '.mpga':
            // MPEG Audio
            mimetype = 'audio/mpeg';
            break;
        case '.mxu':
            // MPEG Url
            mimetype = 'video/vnd.mpegurl';
            break;
        case '.mpeg':
            // MPEG Video
            mimetype = 'video/mpeg';
            break;
        case '.m21':
            // MPEG-21
            mimetype = 'application/mp21';
            break;
        case '.mp4a':
            // MPEG-4 Audio
            mimetype = 'audio/mp4';
            break;
        case '.mp4':
            // MPEG-4 Video
            mimetype = 'video/mp4';
            break;
        case '.mp4':
            // MPEG4
            mimetype = 'application/mp4';
            break;
        case '.m3u8':
            // Multimedia Playlist Unicode
            mimetype = 'application/vnd.apple.mpegurl';
            break;
        case '.mus':
            // MUsical Score Interpreted Code Invented for the ASCII designation of Notation
            mimetype = 'application/vnd.musician';
            break;
        case '.msty':
            // Muvee Automatic Video Editing
            mimetype = 'application/vnd.muvee.style';
            break;
        case '.mxml':
            // MXML
            mimetype = 'application/xv+xml';
            break;
        case '.ngdat':
            // N-Gage Game Data
            mimetype = 'application/vnd.nokia.n-gage.data';
            break;
        case '.n-gage':
            // N-Gage Game Installer
            mimetype = 'application/vnd.nokia.n-gage.symbian.install';
            break;
        case '.ncx':
            // Navigation Control file for XML (for ePub)
            mimetype = 'application/x-dtbncx+xml';
            break;
        case '.nc':
            // Network Common Data Form (NetCDF)
            mimetype = 'application/x-netcdf';
            break;
        case '.nlu':
            // neuroLanguage
            mimetype = 'application/vnd.neurolanguage.nlu';
            break;
        case '.dna':
            // New Moon Liftoff/DNA
            mimetype = 'application/vnd.dna';
            break;
        case '.nnd':
            // NobleNet Directory
            mimetype = 'application/vnd.noblenet-directory';
            break;
        case '.nns':
            // NobleNet Sealer
            mimetype = 'application/vnd.noblenet-sealer';
            break;
        case '.nnw':
            // NobleNet Web
            mimetype = 'application/vnd.noblenet-web';
            break;
        case '.rpst':
            // Nokia Radio Application - Preset
            mimetype = 'application/vnd.nokia.radio-preset';
            break;
        case '.rpss':
            // Nokia Radio Application - Preset
            mimetype = 'application/vnd.nokia.radio-presets';
            break;
        case '.n3':
            // Notation3
            mimetype = 'text/n3';
            break;
        case '.edm':
            // Novadigm's RADIA and EDM products
            mimetype = 'application/vnd.novadigm.edm';
            break;
        case '.edx':
            // Novadigm's RADIA and EDM products
            mimetype = 'application/vnd.novadigm.edx';
            break;
        case '.ext':
            // Novadigm's RADIA and EDM products
            mimetype = 'application/vnd.novadigm.ext';
            break;
        case '.gph':
            // NpGraphIt
            mimetype = 'application/vnd.flographit';
            break;
        case '.ecelp4800':
            // Nuera ECELP 4800
            mimetype = 'audio/vnd.nuera.ecelp4800';
            break;
        case '.ecelp7470':
            // Nuera ECELP 7470
            mimetype = 'audio/vnd.nuera.ecelp7470';
            break;
        case '.ecelp9600':
            // Nuera ECELP 9600
            mimetype = 'audio/vnd.nuera.ecelp9600';
            break;
        case '.oda':
            // Office Document Architecture
            mimetype = 'application/oda';
            break;
        case '.ogx':
            // Ogg
            mimetype = 'application/ogg';
            break;
        case '.oga':
            // Ogg Audio
            mimetype = 'audio/ogg';
            break;
        case '.ogv':
            // Ogg Video
            mimetype = 'video/ogg';
            break;
        case '.dd2':
            // OMA Download Agents
            mimetype = 'application/vnd.oma.dd2+xml';
            break;
        case '.oth':
            // Open Document Text Web
            mimetype = 'application/vnd.oasis.opendocument.text-web';
            break;
        case '.opf':
            // Open eBook Publication Structure
            mimetype = 'application/oebps-package+xml';
            break;
        case '.qbo':
            // Open Financial Exchange
            mimetype = 'application/vnd.intu.qbo';
            break;
        case '.oxt':
            // Open Office Extension
            mimetype = 'application/vnd.openofficeorg.extension';
            break;
        case '.osf':
            // Open Score Format
            mimetype = 'application/vnd.yamaha.openscoreformat';
            break;
        case '.weba':
            // Open Web Media Project - Audio
            mimetype = 'audio/webm';
            break;
        case '.webm':
            // Open Web Media Project - Video
            mimetype = 'video/webm';
            break;
        case '.odc':
            // OpenDocument Chart
            mimetype = 'application/vnd.oasis.opendocument.chart';
            break;
        case '.otc':
            // OpenDocument Chart Template
            mimetype = 'application/vnd.oasis.opendocument.chart-template';
            break;
        case '.odb':
            // OpenDocument Database
            mimetype = 'application/vnd.oasis.opendocument.database';
            break;
        case '.odf':
            // OpenDocument Formula
            mimetype = 'application/vnd.oasis.opendocument.formula';
            break;
        case '.odft':
            // OpenDocument Formula Template
            mimetype = 'application/vnd.oasis.opendocument.formula-template';
            break;
        case '.odg':
            // OpenDocument Graphics
            mimetype = 'application/vnd.oasis.opendocument.graphics';
            break;
        case '.otg':
            // OpenDocument Graphics Template
            mimetype = 'application/vnd.oasis.opendocument.graphics-template';
            break;
        case '.odi':
            // OpenDocument Image
            mimetype = 'application/vnd.oasis.opendocument.image';
            break;
        case '.oti':
            // OpenDocument Image Template
            mimetype = 'application/vnd.oasis.opendocument.image-template';
            break;
        case '.odp':
            // OpenDocument Presentation
            mimetype = 'application/vnd.oasis.opendocument.presentation';
            break;
        case '.otp':
            // OpenDocument Presentation Template
            mimetype = 'application/vnd.oasis.opendocument.presentation-template';
            break;
        case '.ods':
            // OpenDocument Spreadsheet
            mimetype = 'application/vnd.oasis.opendocument.spreadsheet';
            break;
        case '.ots':
            // OpenDocument Spreadsheet Template
            mimetype = 'application/vnd.oasis.opendocument.spreadsheet-template';
            break;
        case '.odt':
            // OpenDocument Text
            mimetype = 'application/vnd.oasis.opendocument.text';
            break;
        case '.odm':
            // OpenDocument Text Master
            mimetype = 'application/vnd.oasis.opendocument.text-master';
            break;
        case '.ott':
            // OpenDocument Text Template
            mimetype = 'application/vnd.oasis.opendocument.text-template';
            break;
        case '.ktx':
            // OpenGL Textures (KTX)
            mimetype = 'image/ktx';
            break;
        case '.sxc':
            // OpenOffice - Calc (Spreadsheet)
            mimetype = 'application/vnd.sun.xml.calc';
            break;
        case '.stc':
            // OpenOffice - Calc Template (Spreadsheet)
            mimetype = 'application/vnd.sun.xml.calc.template';
            break;
        case '.sxd':
            // OpenOffice - Draw (Graphics)
            mimetype = 'application/vnd.sun.xml.draw';
            break;
        case '.std':
            // OpenOffice - Draw Template (Graphics)
            mimetype = 'application/vnd.sun.xml.draw.template';
            break;
        case '.sxi':
            // OpenOffice - Impress (Presentation)
            mimetype = 'application/vnd.sun.xml.impress';
            break;
        case '.sti':
            // OpenOffice - Impress Template (Presentation)
            mimetype = 'application/vnd.sun.xml.impress.template';
            break;
        case '.sxm':
            // OpenOffice - Math (Formula)
            mimetype = 'application/vnd.sun.xml.math';
            break;
        case '.sxw':
            // OpenOffice - Writer (Text - HTML)
            mimetype = 'application/vnd.sun.xml.writer';
            break;
        case '.sxg':
            // OpenOffice - Writer (Text - HTML)
            mimetype = 'application/vnd.sun.xml.writer.global';
            break;
        case '.stw':
            // OpenOffice - Writer Template (Text - HTML)
            mimetype = 'application/vnd.sun.xml.writer.template';
            break;
        case '.otf':
            // OpenType Font File
            mimetype = 'application/x-font-otf';
            break;
        case '.osfpvg':
            // OSFPVG
            mimetype = 'application/vnd.yamaha.openscoreformat.osfpvg+xml';
            break;
        case '.dp':
            // OSGi Deployment Package
            mimetype = 'application/vnd.osgi.dp';
            break;
        case '.pdb':
            // PalmOS Data
            mimetype = 'application/vnd.palm';
            break;
        case '.p':
            // Pascal Source File
            mimetype = 'text/x-pascal';
            break;
        case '.paw':
            // PawaaFILE
            mimetype = 'application/vnd.pawaafile';
            break;
        case '.pclxl':
            // PCL 6 Enhanced (Formely PCL XL)
            mimetype = 'application/vnd.hp-pclxl';
            break;
        case '.efif':
            // Pcsel eFIF File
            mimetype = 'application/vnd.picsel';
            break;
        case '.pcx':
            // PCX Image
            mimetype = 'image/x-pcx';
            break;
        case '.psd':
            // Photoshop Document
            mimetype = 'image/vnd.adobe.photoshop';
            break;
        case '.prf':
            // PICSRules
            mimetype = 'application/pics-rules';
            break;
        case '.pic':
            // PICT Image
            mimetype = 'image/x-pict';
            break;
        case '.chat':
            // pIRCh
            mimetype = 'application/x-chat';
            break;
        case '.p10':
            // PKCS #10 - Certification Request Standard
            mimetype = 'application/pkcs10';
            break;
        case '.p12':
            // PKCS #12 - Personal Information Exchange Syntax Standard
            mimetype = 'application/x-pkcs12';
            break;
        case '.p7m':
            // PKCS #7 - Cryptographic Message Syntax Standard
            mimetype = 'application/pkcs7-mime';
            break;
        case '.p7s':
            // PKCS #7 - Cryptographic Message Syntax Standard
            mimetype = 'application/pkcs7-signature';
            break;
        case '.p7r':
            // PKCS #7 - Cryptographic Message Syntax Standard (Certificate Request Response)
            mimetype = 'application/x-pkcs7-certreqresp';
            break;
        case '.p7b':
            // PKCS #7 - Cryptographic Message Syntax Standard (Certificates)
            mimetype = 'application/x-pkcs7-certificates';
            break;
        case '.p8':
            // PKCS #8 - Private-Key Information Syntax Standard
            mimetype = 'application/pkcs8';
            break;
        case '.plf':
            // PocketLearn Viewers
            mimetype = 'application/vnd.pocketlearn';
            break;
        case '.pnm':
            // Portable Anymap Image
            mimetype = 'image/x-portable-anymap';
            break;
        case '.pbm':
            // Portable Bitmap Format
            mimetype = 'image/x-portable-bitmap';
            break;
        case '.pcf':
            // Portable Compiled Format
            mimetype = 'application/x-font-pcf';
            break;
        case '.pfr':
            // Portable Font Resource
            mimetype = 'application/font-tdpfr';
            break;
        case '.pgn':
            // Portable Game Notation (Chess Games)
            mimetype = 'application/x-chess-pgn';
            break;
        case '.pgm':
            // Portable Graymap Format
            mimetype = 'image/x-portable-graymap';
            break;
        case '.pskcxml':
            // Portable Symmetric Key Container
            mimetype = 'application/pskc+xml';
            break;
        case '.pml':
            // PosML
            mimetype = 'application/vnd.ctc-posml';
            break;
        case '.ai':
            // PostScript
            mimetype = 'application/postscript';
            break;
        case '.pfa':
            // PostScript Fonts
            mimetype = 'application/x-font-type1';
            break;
        case '.pbd':
            // PowerBuilder
            mimetype = 'application/vnd.powerbuilder6';
            break;
        case '':
            // Pretty Good Privacy
            mimetype = 'application/pgp-encrypted';
            break;
        case '.pgp':
            // Pretty Good Privacy - Signature
            mimetype = 'application/pgp-signature';
            break;
        case '.box':
            // Preview Systems ZipLock/VBox
            mimetype = 'application/vnd.previewsystems.box';
            break;
        case '.ptid':
            // Princeton Video Image
            mimetype = 'application/vnd.pvi.ptid1';
            break;
        case '.pls':
            // Pronunciation Lexicon Specification
            mimetype = 'application/pls+xml';
            break;
        case '.str':
            // Proprietary P&G Standard Reporting System
            mimetype = 'application/vnd.pg.format';
            break;
        case '.ei6':
            // Proprietary P&G Standard Reporting System
            mimetype = 'application/vnd.pg.osasli';
            break;
        case '.dsc':
            // PRS Lines Tag
            mimetype = 'text/prs.lines.tag';
            break;
        case '.psf':
            // PSF Fonts
            mimetype = 'application/x-font-linux-psf';
            break;
        case '.qps':
            // PubliShare Objects
            mimetype = 'application/vnd.publishare-delta-tree';
            break;
        case '.wg':
            // Qualcomm's Plaza Mobile Internet
            mimetype = 'application/vnd.pmi.widget';
            break;
        case '.qxd':
            // QuarkXpress
            mimetype = 'application/vnd.quark.quarkxpress';
            break;
        case '.esf':
            // QUASS Stream Player
            mimetype = 'application/vnd.epson.esf';
            break;
        case '.msf':
            // QUASS Stream Player
            mimetype = 'application/vnd.epson.msf';
            break;
        case '.ssf':
            // QUASS Stream Player
            mimetype = 'application/vnd.epson.ssf';
            break;
        case '.qam':
            // QuickAnime Player
            mimetype = 'application/vnd.epson.quickanime';
            break;
        case '.qfx':
            // Quicken
            mimetype = 'application/vnd.intu.qfx';
            break;
        case '.qt':
            // Quicktime Video
            mimetype = 'video/quicktime';
            break;
        case '.rar':
            // RAR Archive
            mimetype = 'application/x-rar-compressed';
            break;
        case '.ram':
            // Real Audio Sound
            mimetype = 'audio/x-pn-realaudio';
            break;
        case '.rmp':
            // Real Audio Sound
            mimetype = 'audio/x-pn-realaudio-plugin';
            break;
        case '.rsd':
            // Really Simple Discovery
            mimetype = 'application/rsd+xml';
            break;
        case '.rm':
            // RealMedia
            mimetype = 'application/vnd.rn-realmedia';
            break;
        case '.mxl':
            // Recordare Applications
            mimetype = 'application/vnd.recordare.musicxml';
            break;
        case '.musicxml':
            // Recordare Applications
            mimetype = 'application/vnd.recordare.musicxml+xml';
            break;
        case '.rnc':
            // Relax NG Compact Syntax
            mimetype = 'application/relax-ng-compact-syntax';
            break;
        case '.rdz':
            // RemoteDocs R-Viewer
            mimetype = 'application/vnd.data-vision.rdz';
            break;
        case '.rdf':
            // Resource Description Framework
            mimetype = 'application/rdf+xml';
            break;
        case '.rp9':
            // RetroPlatform Player
            mimetype = 'application/vnd.cloanto.rp9';
            break;
        case '.jisp':
            // RhymBox
            mimetype = 'application/vnd.jisp';
            break;
        case '.rtf':
            // Rich Text Format
            mimetype = 'application/rtf';
            break;
        case '.rtx':
            // Rich Text Format (RTF)
            mimetype = 'text/richtext';
            break;
        case '.link66':
            // ROUTE 66 Location Based Services
            mimetype = 'application/vnd.route66.link66+xml';
            break;
        case '.rss, .xml':
            // RSS - Really Simple Syndication
            mimetype = 'application/rss+xml';
            break;
        case '.shf':
            // S Hexdump Format
            mimetype = 'application/shf+xml';
            break;
        case '.st':
            // SailingTracker
            mimetype = 'application/vnd.sailingtracker.track';
            break;
        case '.sus':
            // ScheduleUs
            mimetype = 'application/vnd.sus-calendar';
            break;
        case '.sru':
            // Search/Retrieve via URL Response Format
            mimetype = 'application/sru+xml';
            break;
        case '.setpay':
            // Secure Electronic Transaction - Payment
            mimetype = 'application/set-payment-initiation';
            break;
        case '.setreg':
            // Secure Electronic Transaction - Registration
            mimetype = 'application/set-registration-initiation';
            break;
        case '.sema':
            // Secured eMail
            mimetype = 'application/vnd.sema';
            break;
        case '.semd':
            // Secured eMail
            mimetype = 'application/vnd.semd';
            break;
        case '.semf':
            // Secured eMail
            mimetype = 'application/vnd.semf';
            break;
        case '.see':
            // SeeMail
            mimetype = 'application/vnd.seemail';
            break;
        case '.snf':
            // Server Normal Format
            mimetype = 'application/x-font-snf';
            break;
        case '.spq':
            // Server-Based Certificate Validation Protocol - Validation Policies - Request
            mimetype = 'application/scvp-vp-request';
            break;
        case '.spp':
            // Server-Based Certificate Validation Protocol - Validation Policies - Response
            mimetype = 'application/scvp-vp-response';
            break;
        case '.scq':
            // Server-Based Certificate Validation Protocol - Validation Request
            mimetype = 'application/scvp-cv-request';
            break;
        case '.scs':
            // Server-Based Certificate Validation Protocol - Validation Response
            mimetype = 'application/scvp-cv-response';
            break;
        case '.sdp':
            // Session Description Protocol
            mimetype = 'application/sdp';
            break;
        case '.etx':
            // Setext
            mimetype = 'text/x-setext';
            break;
        case '.movie':
            // SGI Movie
            mimetype = 'video/x-sgi-movie';
            break;
        case '.ifm':
            // Shana Informed Filler
            mimetype = 'application/vnd.shana.informed.formdata';
            break;
        case '.itp':
            // Shana Informed Filler
            mimetype = 'application/vnd.shana.informed.formtemplate';
            break;
        case '.iif':
            // Shana Informed Filler
            mimetype = 'application/vnd.shana.informed.interchange';
            break;
        case '.ipk':
            // Shana Informed Filler
            mimetype = 'application/vnd.shana.informed.package';
            break;
        case '.tfi':
            // Sharing Transaction Fraud Data
            mimetype = 'application/thraud+xml';
            break;
        case '.shar':
            // Shell Archive
            mimetype = 'application/x-shar';
            break;
        case '.rgb':
            // Silicon Graphics RGB Bitmap
            mimetype = 'image/x-rgb';
            break;
        case '.slt':
            // SimpleAnimeLite Player
            mimetype = 'application/vnd.epson.salt';
            break;
        case '.aso':
            // Simply Accounting
            mimetype = 'application/vnd.accpac.simply.aso';
            break;
        case '.imp':
            // Simply Accounting - Data Import
            mimetype = 'application/vnd.accpac.simply.imp';
            break;
        case '.twd':
            // SimTech MindMapper
            mimetype = 'application/vnd.simtech-mindmapper';
            break;
        case '.csp':
            // Sixth Floor Media - CommonSpace
            mimetype = 'application/vnd.commonspace';
            break;
        case '.saf':
            // SMAF Audio
            mimetype = 'application/vnd.yamaha.smaf-audio';
            break;
        case '.mmf':
            // SMAF File
            mimetype = 'application/vnd.smaf';
            break;
        case '.spf':
            // SMAF Phrase
            mimetype = 'application/vnd.yamaha.smaf-phrase';
            break;
        case '.teacher':
            // SMART Technologies Apps
            mimetype = 'application/vnd.smart.teacher';
            break;
        case '.svd':
            // SourceView Document
            mimetype = 'application/vnd.svd';
            break;
        case '.rq':
            // SPARQL - Query
            mimetype = 'application/sparql-query';
            break;
        case '.srx':
            // SPARQL - Results
            mimetype = 'application/sparql-results+xml';
            break;
        case '.gram':
            // Speech Recognition Grammar Specification
            mimetype = 'application/srgs';
            break;
        case '.grxml':
            // Speech Recognition Grammar Specification - XML
            mimetype = 'application/srgs+xml';
            break;
        case '.ssml':
            // Speech Synthesis Markup Language
            mimetype = 'application/ssml+xml';
            break;
        case '.skp':
            // SSEYO Koan Play File
            mimetype = 'application/vnd.koan';
            break;
        case '.sgml':
            // Standard Generalized Markup Language (SGML)
            mimetype = 'text/sgml';
            break;
        case '.sdc':
            // StarOffice - Calc
            mimetype = 'application/vnd.stardivision.calc';
            break;
        case '.sdd':
            // StarOffice - Impress
            mimetype = 'application/vnd.stardivision.impress';
            break;
        case '.sdw':
            // StarOffice - Writer
            mimetype = 'application/vnd.stardivision.writer';
            break;
        case '.sm':
            // StepMania
            mimetype = 'application/vnd.stepmania.stepchart';
            break;
        case '.sit':
            // Stuffit Archive
            mimetype = 'application/x-stuffit';
            break;
        case '.sitx':
            // Stuffit Archive
            mimetype = 'application/x-stuffitx';
            break;
        case '.sdkm':
            // SudokuMagic
            mimetype = 'application/vnd.solent.sdkm+xml';
            break;
        case '.xo':
            // Sugar Linux Application Bundle
            mimetype = 'application/vnd.olpc-sugar';
            break;
        case '.au':
            // Sun Audio - Au file format
            mimetype = 'audio/basic';
            break;
        case '.wqd':
            // SundaHus WQ
            mimetype = 'application/vnd.wqd';
            break;
        case '.sis':
            // Symbian Install Package
            mimetype = 'application/vnd.symbian.install';
            break;
        case '.smi':
            // Synchronized Multimedia Integration Language
            mimetype = 'application/smil+xml';
            break;
        case '.xsm':
            // SyncML
            mimetype = 'application/vnd.syncml+xml';
            break;
        case '.bdm':
            // SyncML - Device Management
            mimetype = 'application/vnd.syncml.dm+wbxml';
            break;
        case '.xdm':
            // SyncML - Device Management
            mimetype = 'application/vnd.syncml.dm+xml';
            break;
        case '.sv4cpio':
            // System V Release 4 CPIO Archive
            mimetype = 'application/x-sv4cpio';
            break;
        case '.sv4crc':
            // System V Release 4 CPIO Checksum Data
            mimetype = 'application/x-sv4crc';
            break;
        case '.sbml':
            // Systems Biology Markup Language
            mimetype = 'application/sbml+xml';
            break;
        case '.tsv':
            // Tab Seperated Values
            mimetype = 'text/tab-separated-values';
            break;
        case '.tao':
            // Tao Intent
            mimetype = 'application/vnd.tao.intent-module-archive';
            break;
        case '.tar':
            // Tar File (Tape Archive)
            mimetype = 'application/x-tar';
            break;
        case '.tcl':
            // Tcl Script
            mimetype = 'application/x-tcl';
            break;
        case '.tex':
            // TeX
            mimetype = 'application/x-tex';
            break;
        case '.tfm':
            // TeX Font Metric
            mimetype = 'application/x-tex-tfm';
            break;
        case '.tei':
            // Text Encoding and Interchange
            mimetype = 'application/tei+xml';
            break;
        case '.dxp':
            // TIBCO Spotfire
            mimetype = 'application/vnd.spotfire.dxp';
            break;
        case '.sfs':
            // TIBCO Spotfire
            mimetype = 'application/vnd.spotfire.sfs';
            break;
        case '.tsd':
            // Time Stamped Data Envelope
            mimetype = 'application/timestamped-data';
            break;
        case '.tpt':
            // TRI Systems Config
            mimetype = 'application/vnd.trid.tpt';
            break;
        case '.mxs':
            // Triscape Map Explorer
            mimetype = 'application/vnd.triscape.mxs';
            break;
        case '.t':
            // troff
            mimetype = 'text/troff';
            break;
        case '.tra':
            // True BASIC
            mimetype = 'application/vnd.trueapp';
            break;
        case '.ttf':
            // TrueType Font
            mimetype = 'application/x-font-ttf';
            break;
        case '.ttl':
            // Turtle (Terse RDF Triple Language)
            mimetype = 'text/turtle';
            break;
        case '.umj':
            // UMAJIN
            mimetype = 'application/vnd.umajin';
            break;
        case '.uoml':
            // Unique Object Markup Language
            mimetype = 'application/vnd.uoml+xml';
            break;
        case '.unityweb':
            // Unity 3d
            mimetype = 'application/vnd.unity';
            break;
        case '.ufd':
            // Universal Forms Description Language
            mimetype = 'application/vnd.ufdl';
            break;
        case '.uri':
            // URI Resolution Services
            mimetype = 'text/uri-list';
            break;
        case '.utz':
            // User Interface Quartz - Theme (Symbian)
            mimetype = 'application/vnd.uiq.theme';
            break;
        case '.ustar':
            // Ustar (Uniform Standard Tape Archive)
            mimetype = 'application/x-ustar';
            break;
        case '.uu':
            // UUEncode
            mimetype = 'text/x-uuencode';
            break;
        case '.vcs':
            // vCalendar
            mimetype = 'text/x-vcalendar';
            break;
        case '.vcf':
            // vCard
            mimetype = 'text/x-vcard';
            break;
        case '.vcd':
            // Video CD
            mimetype = 'application/x-cdlink';
            break;
        case '.vsf':
            // Viewport+
            mimetype = 'application/vnd.vsf';
            break;
        case '.wrl':
            // Virtual Reality Modeling Language
            mimetype = 'model/vrml';
            break;
        case '.vcx':
            // VirtualCatalog
            mimetype = 'application/vnd.vcx';
            break;
        case '.mts':
            // Virtue MTS
            mimetype = 'model/vnd.mts';
            break;
        case '.vtu':
            // Virtue VTU
            mimetype = 'model/vnd.vtu';
            break;
        case '.vis':
            // Visionary
            mimetype = 'application/vnd.visionary';
            break;
        case '.viv':
            // Vivo
            mimetype = 'video/vnd.vivo';
            break;
        case '.ccxml':
            // Voice Browser Call Control
            mimetype = 'application/ccxml+xml,';
            break;
        case '.vxml':
            // VoiceXML
            mimetype = 'application/voicexml+xml';
            break;
        case '.src':
            // WAIS Source
            mimetype = 'application/x-wais-source';
            break;
        case '.wbxml':
            // WAP Binary XML (WBXML)
            mimetype = 'application/vnd.wap.wbxml';
            break;
        case '.wbmp':
            // WAP Bitamp (WBMP)
            mimetype = 'image/vnd.wap.wbmp';
            break;
        case '.wav':
            // Waveform Audio File Format (WAV)
            mimetype = 'audio/x-wav';
            break;
        case '.davmount':
            // Web Distributed Authoring and Versioning
            mimetype = 'application/davmount+xml';
            break;
        case '.woff':
            // Web Open Font Format
            mimetype = 'application/x-font-woff';
            break;
        case '.wspolicy':
            // Web Services Policy
            mimetype = 'application/wspolicy+xml';
            break;
        case '.webp':
            // WebP Image
            mimetype = 'image/webp';
            break;
        case '.wtb':
            // WebTurbo
            mimetype = 'application/vnd.webturbo';
            break;
        case '.wgt':
            // Widget Packaging and XML Configuration
            mimetype = 'application/widget';
            break;
        case '.hlp':
            // WinHelp
            mimetype = 'application/winhlp';
            break;
        case '.wml':
            // Wireless Markup Language (WML)
            mimetype = 'text/vnd.wap.wml';
            break;
        case '.wmls':
            // Wireless Markup Language Script (WMLScript)
            mimetype = 'text/vnd.wap.wmlscript';
            break;
        case '.wmlsc':
            // WMLScript
            mimetype = 'application/vnd.wap.wmlscriptc';
            break;
        case '.wpd':
            // Wordperfect
            mimetype = 'application/vnd.wordperfect';
            break;
        case '.stf':
            // Worldtalk
            mimetype = 'application/vnd.wt.stf';
            break;
        case '.wsdl':
            // WSDL - Web Services Description Language
            mimetype = 'application/wsdl+xml';
            break;
        case '.der':
            // X.509 Certificate
            mimetype = 'application/x-x509-ca-cert';
            break;
        case '.fig':
            // Xfig
            mimetype = 'application/x-xfig';
            break;
        case '.xhtml':
            // XHTML - The Extensible HyperText Markup Language
            mimetype = 'application/xhtml+xml';
            break;
        case '.xml':
            // XML - Extensible Markup Language
            mimetype = 'application/xml';
            break;
        case '.xdf':
            // XML Configuration Access Protocol - XCAP Diff
            mimetype = 'application/xcap-diff+xml';
            break;
        case '.xenc':
            // XML Encryption Syntax and Processing
            mimetype = 'application/xenc+xml';
            break;
        case '.xer':
            // XML Patch Framework
            mimetype = 'application/patch-ops-error+xml';
            break;
        case '.rl':
            // XML Resource Lists
            mimetype = 'application/resource-lists+xml';
            break;
        case '.rs':
            // XML Resource Lists
            mimetype = 'application/rls-services+xml';
            break;
        case '.rld':
            // XML Resource Lists Diff
            mimetype = 'application/resource-lists-diff+xml';
            break;
        case '.xslt':
            // XML Transformations
            mimetype = 'application/xslt+xml';
            break;
        case '.xop':
            // XML-Binary Optimized Packaging
            mimetype = 'application/xop+xml';
            break;
        case '.xpi':
            // XPInstall - Mozilla
            mimetype = 'application/x-xpinstall';
            break;
        case '.xspf':
            // XSPF - XML Shareable Playlist Format
            mimetype = 'application/xspf+xml';
            break;
        case '.xul':
            // XUL - XML User Interface Language
            mimetype = 'application/vnd.mozilla.xul+xml';
            break;
        case '.xyz':
            // XYZ File Format
            mimetype = 'chemical/x-xyz';
            break;
        case '.yaml':
            // YAML Ain't Markup Language / Yet Another Markup Language
            mimetype = 'text/yaml';
            break;
        case '.yang':
            // YANG Data Modeling Language
            mimetype = 'application/yang';
            break;
        case '.yin':
            // YIN (YANG - XML)
            mimetype = 'application/yin+xml';
            break;
        case '.zir':
            // Z.U.L. Geometry
            mimetype = 'application/vnd.zul';
            break;
        case '.zip':
            // Zip Archive
            mimetype = 'application/zip';
            break;
        case '.zmm':
            // ZVUE Media Manager
            mimetype = 'application/vnd.handheld-entertainment+xml';
            break;
        case '.zaz':
            // Zzazz Deck
            mimetype = 'application/vnd.zzazz.deck+xml';
            break;
        default:
            // Binary Data
            mimetype = 'application/octet-stream';
            break;
        }
     
        return mimetype;
    }

  6. #6
    Expert confirmé
    Avatar de Watilin
    Homme Profil pro
    En recherche d'emploi
    Inscrit en
    Juin 2010
    Messages
    3 100
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : En recherche d'emploi

    Informations forums :
    Inscription : Juin 2010
    Messages : 3 100
    Par défaut
    Citation Envoyé par Zebulon777 Voir le message
    Nous n'avons pas de problème de sécurité parce que cette application ne fonctionne qu'en intranet.
    Et si l’intranet était compromis ? En sécurité informatique, il ne faut jamais penser que quelque chose est impossible. Il peut se passer deux choses :
    • la sécurité que tu tenais pour solide (ici, l’intranet) s’avère défaillante, et ton application, qui n’a pas de sécurité propre, est alors complètement vulnérable ;
    • ton application elle-même sert de vecteur d’attaque pour toucher des parties plus sécurisées du système.

    En l’occurence il suffit de comparer deux chaînes de caractère (j’ai oublié de mentionner que tu peux aussi t’aider de dirname), avoue que ce n’est pas trop compliqué

    Citation Envoyé par Zebulon777 Voir le message
    j'ai pas mal avancé, surtout grâce à des recherches sur le net et je suis tombé sur ce script qui correspond exactement à ce que nous voulons faire.
    Mais le souci, c'est qu'il faut absolument passer par un bouton "Parcourir".

    Je cherche donc à remplacer la sélection par le bouton "Parcourir" par le nom du fichier directement, mais pour le moment, c'est chou blanc.
    D'ailleurs est-ce que c'est possible ?
    Je ne suis pas sûr de comprendre le besoin. Avant tu avais un fichier envoyé par le serveur au client et tu voulais qu’il soit enregistré sur le poste client ; maintenant tu veux utiliser un bouton parcourir pour envoyer un fichier au serveur ?

    Le bouton parcourir, en tant que « porte d’accès » au système de fichiers depuis le navigateur, est soumis à beaucoup de restrictions. Entre autres :
    • le script ne peut pas connaître le chemin du fichier, seulement son nom ;
    • le fichier est ouvert en lecture seule.

    Si ton but est toujours, comme je l’ai compris, d’enregistrer un fichier sur le poste client, le bouton parcourir ne permet pas de faire ça.
    La FAQ JavaScript – Les cours JavaScript
    Touche F12 = la console → l’outil indispensable pour développer en JavaScript !

  7. #7
    Membre éprouvé Avatar de Zebulon777
    Homme Profil pro
    Informaticien
    Inscrit en
    Février 2005
    Messages
    1 327
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Informaticien

    Informations forums :
    Inscription : Février 2005
    Messages : 1 327
    Par défaut
    Tout d'abord merci pour ton aide et tes conseils.

    Je pense que je me suis mal fait comprendre : notre application récupère un grand nombre de données dans une BDD et notamment des chemins d'accès + fichiers que nous devons proposer à nos utilisateurs soit d'ouvrir directement soit d'enregistrer localement s'ils le désirent.

    Ce que nous avons fait fonctionne très bien avec les fichiers TXT et les fichiers CSV, mais impossible d'avoir le même fonctionnement avec les fichiers Excel.

    La fonction en cours de développement est celle-ci :
    Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
     
    function OuvreFic(P_Fichier)
    {
    	writeFile(G_FICLOG, "OuvreFic(" + P_Fichier + ")", "OUI");
     
    	alert("Ouverture du fichier : " + P_Fichier);
     
    //	download_bis(P_Fichier, "il faut lire le fichier texte pour le charger");
     
        $.ajax(
        {
            type: "POST",
            url: "./PHP/fileReader.php",
            data: {NomFichier : P_Fichier},
            async: false,
            error : function()
            {
                alert("Echec de l'envoi de la requête -> fileReader.php : " + P_Fichier);
            },
            success: function(data)
            {
    			let WType = P_Fichier.substring(P_Fichier.length - 4, P_Fichier.length);
    			WType = WType.toUpperCase();
    // Le fichier est lu pour pouvoir en demander - ensuite - l'ouverture ou l'enregistrement.
    			if (WType == ".TXT" || WType == ".CSV")
    			{
    				download(P_Fichier, data);
    			}
    			else
    			{
    				if (WType == ".XLS" || WType == "XLSX")
    				{
    //			download_bis(P_Fichier, data, WType)
    //       saveAs(new Blob([data],{type:"application/vnd.ms-excel"}), P_Fichier);
    P_Fichier = "\\volume1\\web\\CTRL_BDD_MULTIVAC_SG\\tests\\2020_01_01_CDG.XLSX";					
    //P_Fichier = "CTRL_BDD_MULTIVAC_SG/tests/2020_01_01_CDG.XLSX";					
    console.log("P_Fichier="+P_Fichier);				
    //window.open(P_Fichier);
    //	var blob = new Blob([data], {type: "application/vnd.ms-excel"});
    //	saveAs(blob, P_Fichier);
     
    //					readSingleFile(P_Fichier);
     
     
    				}
    				else
    				{
    					alert("Impossible de lire le fichier " + P_Fichier);
    				}
    			}
    		}
        });
    }

    Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    function download(filename, text) {
    	var blob = new Blob([text], {type: "text/plain;charset=utf-8"});
    	saveAs(blob, filename);
    }

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
     
    <?php
    	$file=$_POST['NomFichier'];
     
    	header("Content-type: text/plain; charset=utf-8"); 
     
    	header("Content-Disposition: attachment; filename=\"" . $file . "\"");
    	header("Expires: 0");
    	header("Cache-Control: no-cache, must-revalidate");
    	header("Pragma: no-cache");
     
    	readfile($file);
     
    	echo("file=" . $file);
     
    ?>

    Il ne nous manque donc plus que le traitement des fichiers Excel (donc binaire,je crois ?)
    Et c'est cette partie-là sur laquelle nous butons encore ; c'est surtout à ce niveau là que je compte sur les beaucoup plus doués que moi

    Donc, en plus de mon appel à l'aide j'explore tout ce que je peux trouver et je fais des essais, qui ne sont pas concluant pour le moment.

    En ce qui concerne tes remarques sur la sécurité, j'ai fait remonter les informations, mais je ne suis pas le seul sur l'appli et je ne prends pas les décisions.
    On essaye d'avancer petit à petit et on prend les problèmes de la même manière.
    (Je ne connaissais pas dirname, et en allant voir, j'ai aussi trouvé pathinfo que je trouve tout aussi intéressant, merci)

  8. #8
    Expert confirmé
    Avatar de Watilin
    Homme Profil pro
    En recherche d'emploi
    Inscrit en
    Juin 2010
    Messages
    3 100
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : En recherche d'emploi

    Informations forums :
    Inscription : Juin 2010
    Messages : 3 100
    Par défaut
    Il y a toujours un truc que je ne comprends pas à propos de ce bouton parcourir.
    Citation Envoyé par Zebulon777 Voir le message
    j'ai pas mal avancé, surtout grâce à des recherches sur le net et je suis tombé sur ce script qui correspond exactement à ce que nous voulons faire.
    Mais le souci, c'est qu'il faut absolument passer par un bouton "Parcourir".

    Je cherche donc à remplacer la sélection par le bouton "Parcourir" par le nom du fichier directement, mais pour le moment, c'est chou blanc.
    Afin de lever toute ambigüité, je précise un truc qui est peut-être évident : le bouton parcourir ne peut parcourir que le système de fichiers du poste client.
    Si tu veux mettre en œuvre un mécanisme similaire permettant de consulter le système de fichiers du serveur depuis le client, tu dois le faire à la main, et ça va demander pas mal de codage. Il faut au minimum :
    • un script client qui demande le contenu d’un dossier pour un chemin donné ;
    • un script serveur qui répond avec la liste des fichiers, dossiers, voire sous-dossiers récursivement (mais attention à respecter les permissions).

    C’est là qu’on réalise que le bouton parcourir fait beaucoup de choses Tout ça, tu t’en doutes, nécessite une attention particulière à la sécurité, mais aussi à l’ergonomie. Ici, pas question de faire de l’ajax synchrone car il y a potentiellement de nombreux allers-retours entre le client et le serveur, et des requêtes bloquantes rendraient l’expérience utilisateur horrible.

    Citation Envoyé par Zebulon777 Voir le message
    Ce que nous avons fait fonctionne très bien avec les fichiers TXT et les fichiers CSV, mais impossible d'avoir le même fonctionnement avec les fichiers Excel.
    Qu’est-ce que tu veux dire exactement par « fonctionne très bien » ? Quel est le comportement attendu ?

    Citation Envoyé par Zebulon777 Voir le message
    La fonction en cours de développement est celle-ci :
    [...du code...]
    Il y a dans ce code une fonction saveAs qui n’est pas définie. Je peux tenter de deviner que tu utilises une bibliothèque comme FileSaver, mais en réalité je ne peux pas savoir avec certitude ce que fait cette fonction. Peux-tu me la montrer si c’est possible*?

    Citation Envoyé par Zebulon777 Voir le message
    Il ne nous manque donc plus que le traitement des fichiers Excel (donc binaire,je crois ?)
    Oui. Plus précisément, un fichier Excel est une archive ZIP contenant principalement des fichiers XML.

    Vu que tu dis que l’application est en intranet, il y a une autre solution à envisager : configurer les navigateurs de tous les postes clients pour qu’ils traitent les fichiers Excel (et autres) de la façon attendue. Je ne sais pas si c’est faisable dans ton entreprise, mais c’est à mon avis la solution la plus robuste
    La FAQ JavaScript – Les cours JavaScript
    Touche F12 = la console → l’outil indispensable pour développer en JavaScript !

  9. #9
    Membre éprouvé Avatar de Zebulon777
    Homme Profil pro
    Informaticien
    Inscrit en
    Février 2005
    Messages
    1 327
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Informaticien

    Informations forums :
    Inscription : Février 2005
    Messages : 1 327
    Par défaut
    Ho la la, j'ai vraiment pas été assez précis Désolé.

    Oui, oui, effectivement, nous utilisons FileSaver.js.

    Le comportement attendu est l'affichage de la boite modal permettant d'ouvrir ou d'enregistrer le fichier sélectionné.
    Nom : Enr.png
Affichages : 352
Taille : 12,8 Ko

    L'application et la BDD seront sur un gros NAS Synology et les fichiers à récupérer seront du type :

    /mnt/nas03/Rep1/Rep2/Rep3/Nomfichier.xls
    ou
    //192.1.1.xx/Rep1/Rep2/Rep3/Nomfichier.xls
    ou
    //172.16.xx.xx/Rep1/Rep2/Rep3/Nomfichier.xls

    Les différentes machines cibles sont toutes des machines Linux (Ubuntu, Debian ou Synology DSM à jour) sur lesquelles les droits d'accès lecture / écriture sont correctement configurés, puisque nos autres appli fonctionnent, mais je n'ai pas accès à cette partie de la configuration, ou plutôt, je ne connais pas assez bien pour y tripatouiller

    Parallèlement à ton aide, mon fils travaille aussi sur une solution (pour m'aider) que nous sommes entrain de développer et tester (vive le confinement ! ) que je partage ici, ne serait-ce que pour avoir des retours.

    Elle semble fonctionner correctement à la maison, mais il va falloir que je la teste à fond au bureau, dés que possible.

    Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    893
    894
    895
    896
    897
    898
    899
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    930
    931
    932
    933
    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    950
    951
    952
    953
    954
    955
    956
    957
    958
    959
    960
    961
    962
    963
    964
    965
    966
    967
    968
    969
    970
    971
    972
    973
    974
    975
    976
    977
    978
    979
    980
    981
    982
    983
    984
    985
    986
    987
    988
    989
    990
    991
    992
    993
    994
    995
    996
    997
    998
    999
    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    1026
    1027
    1028
    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    1040
    1041
    1042
    1043
    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    1061
    1062
    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    1080
    1081
    1082
    1083
    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    1097
    1098
    1099
    1100
    1101
    1102
    1103
    1104
    1105
    1106
    1107
    1108
    1109
    1110
    1111
    1112
    1113
    1114
    1115
    1116
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    1124
    1125
    1126
    1127
    1128
    1129
    1130
    1131
    1132
    1133
    1134
    1135
    1136
    1137
    1138
    1139
    1140
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    1150
    1151
    1152
    1153
    1154
    1155
    1156
    1157
    1158
    1159
    1160
    1161
    1162
    1163
    1164
    1165
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    1176
    1177
    1178
    1179
    1180
    1181
    1182
    1183
    1184
    1185
    1186
    1187
    1188
    1189
    1190
    1191
    1192
    1193
    1194
    1195
    1196
    1197
    1198
    1199
    1200
    1201
    1202
    1203
    1204
    1205
    1206
    1207
    1208
    1209
    1210
    1211
    1212
    1213
    1214
    1215
    1216
    1217
    1218
    1219
    1220
    1221
    1222
    1223
    1224
    1225
    1226
    1227
    1228
    1229
    1230
    1231
    1232
    1233
    1234
    1235
    1236
    1237
    1238
    1239
    1240
    1241
    1242
    1243
    1244
    1245
    1246
    1247
    1248
    1249
    1250
    1251
    1252
    1253
    1254
    1255
    1256
    1257
    1258
    1259
    1260
    1261
    1262
    1263
    1264
    1265
    1266
    1267
    1268
    1269
    1270
    1271
    1272
    1273
    1274
    1275
    1276
    1277
    1278
    1279
    1280
    1281
    1282
    1283
    1284
    1285
    1286
    1287
    1288
    1289
    1290
    1291
    1292
    1293
    1294
    1295
    1296
    1297
    1298
    1299
    1300
    1301
    1302
    1303
    1304
    1305
    1306
    1307
    1308
    1309
    1310
    1311
    1312
    1313
    1314
    1315
    1316
    1317
    1318
    1319
    1320
    1321
    1322
    1323
    1324
    1325
    1326
    1327
    1328
    1329
    1330
    1331
    1332
    1333
    1334
    1335
    1336
    1337
    1338
    1339
    1340
    1341
    1342
    1343
    1344
    1345
    1346
    1347
    1348
    1349
    1350
    1351
    1352
    1353
    1354
    1355
    1356
    1357
    1358
    1359
    1360
    1361
    1362
    1363
    1364
    1365
    1366
    1367
    1368
    1369
    1370
    1371
    1372
    1373
    1374
    1375
    1376
    1377
    1378
    1379
    1380
    1381
    1382
    1383
    1384
    1385
    1386
    1387
    1388
    1389
    1390
    1391
    1392
    1393
    1394
    1395
    1396
    1397
    1398
    1399
    1400
    1401
    1402
    1403
    1404
    1405
    1406
    1407
    1408
    1409
    1410
    1411
    1412
    1413
    1414
    1415
    1416
    1417
    1418
    1419
    1420
    1421
    1422
    1423
    1424
    1425
    1426
    1427
    1428
    1429
    1430
    1431
    1432
    1433
    1434
    1435
    1436
    1437
    1438
    1439
    1440
    1441
    1442
    1443
    1444
    1445
    1446
    1447
    1448
    1449
    1450
    1451
    1452
    1453
    1454
    1455
    1456
    1457
    1458
    1459
    1460
    1461
    1462
    1463
    1464
    1465
    1466
    1467
    1468
    1469
    1470
    1471
    1472
    1473
    1474
    1475
    1476
    1477
    1478
    1479
    1480
    1481
    1482
    1483
    1484
    1485
    1486
    1487
    1488
    1489
    1490
    1491
    1492
    1493
    1494
    1495
    1496
    1497
    1498
    1499
    1500
    1501
    1502
    1503
    1504
    1505
    1506
    1507
    1508
    1509
    1510
    1511
    1512
    1513
    1514
    1515
    1516
    1517
    1518
    1519
    1520
    1521
    1522
    1523
    1524
    1525
    1526
    1527
    1528
    1529
    1530
    1531
    1532
    1533
    1534
    1535
    1536
    1537
    1538
    1539
    1540
    1541
    1542
    1543
    1544
    1545
    1546
    1547
    1548
    1549
    1550
    1551
    1552
    1553
    1554
    1555
    1556
    1557
    1558
    1559
    1560
    1561
    1562
    1563
    1564
    1565
    1566
    1567
    1568
    1569
    1570
    1571
    1572
    1573
    1574
    1575
    1576
    1577
    1578
    1579
    1580
    1581
    1582
    1583
    1584
    1585
    1586
    1587
    1588
    1589
    1590
    1591
    1592
    1593
    1594
    1595
    1596
    1597
    1598
    1599
    1600
    1601
    1602
    1603
    1604
    1605
    1606
    1607
    1608
    1609
    1610
    1611
    1612
    1613
    1614
    1615
    1616
    1617
    1618
    1619
    1620
    1621
    1622
    1623
    1624
    1625
    1626
    1627
    1628
    1629
    1630
    1631
    1632
    1633
    1634
    1635
    1636
    1637
    1638
    1639
    1640
    1641
    1642
    1643
    1644
    1645
    1646
    1647
    1648
    1649
    1650
    1651
    1652
    1653
    1654
    1655
    1656
    1657
    1658
    1659
    1660
    1661
    1662
    1663
    1664
    1665
    1666
    1667
    1668
    1669
    1670
    1671
    1672
    1673
    1674
    1675
    1676
    1677
    1678
    1679
    1680
    1681
    1682
    1683
    1684
    1685
    1686
    1687
    1688
    1689
    1690
    1691
    1692
    1693
    1694
    1695
    1696
    1697
    1698
    1699
    1700
    1701
    1702
    1703
    1704
    1705
    1706
    1707
    1708
    1709
    1710
    1711
    1712
    1713
    1714
    1715
    1716
    1717
    1718
    1719
    1720
    1721
    1722
    1723
    1724
    1725
    1726
    1727
    1728
    1729
    1730
    1731
    1732
    1733
    1734
    1735
    1736
    1737
    1738
    1739
    1740
    1741
    1742
    1743
    1744
    1745
    1746
    1747
    1748
    1749
    1750
    1751
    1752
    1753
    1754
    1755
    1756
    1757
    1758
    1759
    1760
    1761
    1762
    1763
    1764
    1765
    1766
    1767
    1768
    1769
    1770
    1771
    1772
    1773
    1774
    1775
    1776
    1777
    1778
    1779
    1780
    1781
    1782
    1783
    1784
    1785
    1786
    1787
    1788
    1789
    1790
    1791
    1792
    1793
    1794
    1795
    1796
    1797
    1798
    1799
    1800
    1801
    1802
    1803
    1804
    1805
    1806
    1807
    1808
    1809
    1810
    1811
    1812
    1813
    1814
    1815
    1816
    1817
    1818
    1819
    1820
    1821
    1822
    1823
    1824
    1825
    1826
    1827
    1828
    1829
    1830
    1831
    1832
    1833
    1834
    1835
    1836
    1837
    1838
    1839
    1840
    1841
    1842
    1843
    1844
    1845
    1846
    1847
    1848
    1849
    1850
    1851
    1852
    1853
    1854
    1855
    1856
    1857
    1858
    1859
    1860
    1861
    1862
    1863
    1864
    1865
    1866
    1867
    1868
    1869
    1870
    1871
    1872
    1873
    1874
    1875
    1876
    1877
    1878
    1879
    1880
    1881
    1882
    1883
    1884
    1885
    1886
    1887
    1888
    1889
    1890
    1891
    1892
    1893
    1894
    1895
    1896
    1897
    1898
    1899
    1900
    1901
    1902
    1903
    1904
    1905
    1906
    1907
    1908
    1909
    1910
    1911
    1912
    1913
    1914
    1915
    1916
    1917
    1918
    1919
    1920
    1921
    1922
    1923
    1924
    1925
    1926
    1927
    1928
    1929
    1930
    1931
    1932
    1933
    1934
    1935
    1936
    1937
    1938
    1939
    1940
    1941
    1942
    1943
    1944
    1945
    1946
    1947
    1948
    1949
    1950
    1951
    1952
    1953
    1954
    1955
    1956
    1957
    1958
    1959
    1960
    1961
    1962
    1963
    1964
    1965
    1966
    1967
    1968
    1969
    1970
    1971
    1972
    1973
    1974
    1975
    1976
    1977
    1978
    1979
    1980
    1981
    1982
    1983
    1984
    1985
    1986
    1987
    1988
    1989
    1990
    1991
    1992
    1993
    1994
    1995
    1996
    1997
    1998
    1999
    2000
    2001
    2002
    2003
    2004
    2005
    2006
    2007
    2008
    2009
    2010
    2011
    2012
    2013
    2014
    2015
    2016
    2017
    2018
    2019
    2020
    2021
    2022
    2023
    2024
    2025
    2026
    2027
    2028
    2029
    2030
    2031
    2032
    2033
    2034
    2035
    2036
    2037
    2038
    2039
    2040
    2041
    2042
    2043
    2044
    2045
    2046
    2047
    2048
    2049
    2050
    2051
    2052
    2053
    2054
    2055
    2056
    2057
    2058
    2059
    2060
    2061
    2062
    2063
    2064
    2065
    2066
    2067
    2068
    2069
    2070
    2071
    2072
    2073
    2074
    2075
    2076
    2077
    2078
    2079
    2080
    2081
    2082
    2083
    2084
    2085
    2086
    2087
    2088
    2089
    2090
    2091
    2092
    2093
    2094
    2095
    2096
    2097
    2098
    2099
    2100
    2101
    2102
    2103
    2104
    2105
    2106
    2107
    2108
    2109
    2110
    2111
    2112
    2113
    2114
    2115
    2116
    2117
    2118
    2119
    2120
    2121
    2122
    2123
    2124
    2125
    2126
    2127
    2128
    2129
    2130
    2131
    2132
    2133
    2134
    2135
    2136
    2137
    2138
    2139
    2140
    2141
    2142
    2143
    2144
    2145
    2146
    2147
    2148
    2149
    2150
    2151
    2152
    2153
    2154
    2155
    2156
    2157
    2158
    2159
    2160
    2161
    2162
    2163
    2164
    2165
    2166
    2167
    2168
    2169
    2170
    2171
    2172
    2173
    2174
    2175
    2176
    2177
    2178
    2179
    2180
    2181
    2182
    2183
    2184
    2185
    2186
    2187
    2188
    2189
    2190
    2191
    2192
    2193
    2194
    2195
    2196
    2197
    2198
    2199
    2200
    2201
    2202
    2203
    2204
    2205
    2206
    2207
    2208
    2209
    2210
    2211
    2212
    2213
    2214
    2215
    2216
    2217
    2218
    2219
    2220
    2221
    2222
    2223
    2224
    2225
    2226
    2227
    2228
    2229
    2230
    2231
    2232
    2233
    2234
    2235
    2236
    2237
    2238
    2239
    2240
    2241
    2242
    2243
    2244
    2245
    2246
    2247
    2248
    2249
    2250
    2251
    2252
    2253
    2254
    2255
    2256
    2257
    2258
    2259
    2260
    2261
    2262
    2263
    2264
    2265
    2266
    2267
    2268
    2269
    2270
    2271
    2272
    2273
    2274
    2275
    2276
    2277
    2278
    2279
    2280
    2281
    2282
    2283
    2284
    2285
    2286
    2287
    2288
    2289
    2290
    2291
    2292
    2293
    2294
    2295
    2296
    2297
    2298
    2299
    2300
    2301
    2302
    2303
    2304
    2305
    2306
    2307
    2308
    2309
    2310
    2311
    2312
    2313
    2314
    2315
    2316
    2317
    2318
    2319
    2320
    2321
    2322
    2323
    2324
    2325
    2326
    2327
    2328
    2329
    2330
    2331
    2332
    2333
    2334
    2335
    2336
    2337
    2338
    2339
    2340
    2341
    2342
    2343
    2344
    2345
    2346
    2347
    2348
    2349
    2350
    2351
    2352
    2353
    2354
    2355
    2356
    2357
    2358
    2359
    2360
    2361
    2362
    2363
    2364
    2365
    2366
    2367
    2368
    2369
    2370
    2371
    2372
    2373
    2374
    2375
    2376
    2377
    2378
    2379
    2380
    2381
    2382
    2383
    2384
    2385
    2386
    2387
    2388
    2389
    2390
    2391
    2392
    2393
    2394
    2395
    2396
    2397
    2398
    2399
    2400
    2401
    2402
    2403
    2404
    2405
    2406
    2407
    2408
    2409
    2410
    2411
    2412
    2413
    2414
    2415
    2416
    2417
    2418
    2419
    2420
    2421
    2422
    2423
    2424
    2425
    2426
    2427
    2428
    2429
    2430
    2431
    2432
    2433
    2434
    2435
    2436
    2437
    2438
    2439
    2440
    2441
    2442
    2443
    2444
    2445
    2446
    2447
    2448
    2449
    2450
    2451
    2452
    2453
    2454
    2455
    2456
    2457
    2458
    2459
    2460
    2461
    2462
    2463
    2464
    2465
    2466
    2467
    2468
    2469
    2470
    2471
    2472
    2473
    2474
    2475
    2476
    2477
    2478
    2479
    2480
    2481
    2482
    2483
    2484
    2485
    2486
    2487
    2488
    2489
    2490
    2491
    2492
    2493
    2494
    2495
    2496
    2497
    2498
    2499
    2500
    2501
    2502
    2503
    2504
    2505
    2506
    2507
    2508
    2509
    2510
    2511
    2512
    2513
    2514
    2515
    2516
    2517
    2518
    2519
    2520
    2521
    2522
    2523
    2524
    2525
    2526
    2527
    2528
    2529
    2530
    2531
    2532
    2533
    2534
    2535
    2536
    2537
    2538
    2539
    2540
    2541
    2542
    2543
    2544
    2545
    2546
    2547
    2548
    2549
    2550
    2551
    2552
    2553
    2554
    2555
    2556
    2557
    2558
    2559
    2560
    2561
    2562
    2563
    2564
    2565
    2566
    2567
    2568
    2569
    2570
    2571
    2572
    2573
    2574
    2575
    2576
    2577
    2578
    2579
    2580
    2581
    2582
    2583
    2584
    2585
    2586
    2587
    2588
    2589
    2590
    2591
    2592
    2593
    2594
    2595
    2596
    2597
    2598
    2599
    2600
    2601
    2602
    2603
    2604
    2605
    2606
    2607
    2608
    2609
    2610
    2611
    2612
    2613
    2614
    2615
    2616
    2617
    2618
    2619
    2620
    2621
    2622
    2623
    2624
    2625
    2626
    2627
    2628
    2629
    2630
    2631
    2632
    2633
    2634
    2635
    2636
    2637
    2638
    2639
    2640
    2641
    2642
    2643
    2644
    2645
    2646
    2647
    2648
    2649
    2650
    2651
    2652
    2653
    2654
    2655
    2656
    2657
    2658
    2659
    2660
    2661
    2662
    2663
    2664
    2665
    2666
    2667
    2668
    2669
    2670
    2671
    2672
    2673
    2674
    2675
    2676
    2677
    2678
    2679
    2680
    2681
    2682
    2683
    2684
    2685
    2686
    2687
    2688
    2689
    2690
    2691
    2692
    2693
    2694
    2695
    2696
    2697
    2698
    2699
    2700
    2701
    2702
    2703
    2704
    2705
    2706
    2707
    2708
    2709
    2710
    2711
    2712
    2713
    2714
    2715
    2716
    2717
    2718
    2719
    2720
    2721
    2722
    2723
    2724
    2725
    2726
    2727
    2728
    2729
    2730
    2731
    2732
    2733
    2734
    2735
    2736
    2737
    2738
    2739
    2740
    2741
    2742
    2743
    2744
    2745
    2746
    2747
    2748
    2749
    2750
    2751
    2752
    2753
    2754
    2755
    2756
    2757
    2758
    2759
    2760
    2761
    2762
    2763
    2764
    2765
    2766
    2767
    2768
    2769
    2770
    2771
    2772
    2773
    2774
    2775
    2776
    2777
    2778
    2779
    2780
    2781
    2782
    2783
    2784
    2785
     
    async function downloadTest(filePath)
    {
    // filePath = chemin d'accès complet au fichier avec le nom du fichier
    // ex: 192.168.1.14/Rep/Nomfichier.ext
     
    	let extension = filePath.substring(filePath.lastIndexOf('.'));
    	let mimetype = getMimetype(extension);
     
    	let response = await fetch(filePath, {method: "POST"});
    	let data = await response.blob();
    	let metadata = {
    	type: mimetype
    	};
     
    	let filename = filePath.substring(filePath.lastIndexOf('/') + 1);
    	console.log(filename);
    	let file = new File([data], filename, metadata);
     
    	let dataURL = filePath;
     
    	switch (response.status)
    	{
    		case 200:
    			let a = document.createElement("a");
    			a.download = file.name;
    			a.href = dataURL;
    			document.body.appendChild(a);
    			a.click();
    			document.body.removeChild(a);
    			writeFile(G_FICLOG, "TELECHARGEMENT : " + filePath + " - Status : " + response.status + " - " + response.statusText, "OUI");
    			break;
     
    		case 404:
    			alert("Le fichier que vous avez demandé n'existe pas, ou le chemin précisé est incorrect ( " + response.url + " ).");
    			console.warn("r="+response);
    			writeFile(G_FICLOG, "TELECHARGEMENT : " + filePath + " - Status : " + response.status + " - " + response.statusText, "OUI");
    			break;
     
    		case 405:
    			alert("Problème de droits d'accès.")
    			console.warn(response);
    			writeFile(G_FICLOG, "TELECHARGEMENT : " + filePath + " - Status : " + response.status + " - " + response.statusText, "OUI");
    			break;
     
    		default:
    			alert("Erreur - status : " + response.status);
    			console.warn(response);
    			writeFile(G_FICLOG, "TELECHARGEMENT : " + filePath + " - Status : " + response.status + " - " + response.statusText, "OUI");
    			break;
    	}
    }
     
    /**
     * getMimetype finns som egen fil under istools2/mimetypes.js
     * - module.exports = getMimetype;
     */
    function getMimetype (extension) {
     
        var mimetype;
     
        switch (extension) {
            case '.gif':
            // Graphics Interchange Format
            mimetype = 'image/gif';
            break;
        case '.jpm':
            // JPEG 2000 Compound Image File Format
            mimetype = 'video/jpm';
            break;
        case '.jpeg':
        case '.jpg':
            // JPEG Image
            mimetype = 'image/jpeg';
            break;
        case '.jpgv':
            // JPGVideo
            mimetype = 'video/jpeg';
            break;
        case '.png':
            // Portable Network Graphics (PNG)
            mimetype = 'image/png';
            break;
        case '.ppm':
            // Portable Pixmap Format
            mimetype = 'image/x-portable-pixmap';
            break;
        case '.svg':
            // Scalable Vector Graphics (SVG)
            mimetype = 'image/svg+xml';
            break;
        case '.tiff':
            // Tagged Image File Format
            mimetype = 'image/tiff';
            break;
        case '.xbm':
            // X BitMap
            mimetype = 'image/x-xbitmap';
            break;
        case '.xpm':
            // X PixMap
            mimetype = 'image/x-xpixmap';
            break;
        case '.xwd':
            // X Window Dump
            mimetype = 'image/x-xwindowdump';
            break;
        case '.mdb':
            // Microsoft Access
            mimetype = 'application/x-msaccess';
            break;
        case '.xls':
            // Microsoft Excel
            mimetype = 'application/vnd.ms-excel';
            break;
        case '.xlam':
            // Microsoft Excel - Add-In File
            mimetype = 'application/vnd.ms-excel.addin.macroenabled.12';
            break;
        case '.xlsb':
            // Microsoft Excel - Binary Workbook
            mimetype = 'application/vnd.ms-excel.sheet.binary.macroenabled.12';
            break;
        case '.xltm':
            // Microsoft Excel - Macro-Enabled Template File
            mimetype = 'application/vnd.ms-excel.template.macroenabled.12';
            break;
        case '.xlsm':
            // Microsoft Excel - Macro-Enabled Workbook
            mimetype = 'application/vnd.ms-excel.sheet.macroenabled.12';
            break;
        case '.pptx':
            // Microsoft Office - OOXML - Presentation
            mimetype = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
            break;
        case '.sldx':
            // Microsoft Office - OOXML - Presentation (Slide)
            mimetype = 'application/vnd.openxmlformats-officedocument.presentationml.slide';
            break;
        case '.ppsx':
            // Microsoft Office - OOXML - Presentation (Slideshow)
            mimetype = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow';
            break;
        case '.potx':
            // Microsoft Office - OOXML - Presentation Template
            mimetype = 'application/vnd.openxmlformats-officedocument.presentationml.template';
            break;
        case '.xlsx':
            // Microsoft Office - OOXML - Spreadsheet
            mimetype = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
            break;
        case '.xltx':
            // Microsoft Office - OOXML - Spreadsheet Teplate
            mimetype = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template';
            break;
        case '.docx':
            // Microsoft Office - OOXML - Word Document
            mimetype = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
            break;
        case '.dotx':
            // Microsoft Office - OOXML - Word Document Template
            mimetype = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template';
            break;
        case '.ppt':
            // Microsoft PowerPoint
            mimetype = 'application/vnd.ms-powerpoint';
            break;
        case '.ppam':
            // Microsoft PowerPoint - Add-in file
            mimetype = 'application/vnd.ms-powerpoint.addin.macroenabled.12';
            break;
        case '.sldm':
            // Microsoft PowerPoint - Macro-Enabled Open XML Slide
            mimetype = 'application/vnd.ms-powerpoint.slide.macroenabled.12';
            break;
        case '.pptm':
            // Microsoft PowerPoint - Macro-Enabled Presentation File
            mimetype = 'application/vnd.ms-powerpoint.presentation.macroenabled.12';
            break;
        case '.ppsm':
            // Microsoft PowerPoint - Macro-Enabled Slide Show File
            mimetype = 'application/vnd.ms-powerpoint.slideshow.macroenabled.12';
            break;
        case '.mpp':
            // Microsoft Project
            mimetype = 'application/vnd.ms-project';
            break;
        case '.doc':
            // Microsoft Word
            mimetype = 'application/msword';
            break;
        case '.wri':
            // Microsoft Wordpad
            mimetype = 'application/x-mswrite';
            break;
        case '.wps':
            // Microsoft Works
            mimetype = 'application/vnd.ms-works';
            break;
        case '.pdf':
            // Adobe Portable Document Format
            mimetype = 'application/pdf';
            break;
        case '.txt':
            // Text File
            mimetype = 'text/plain';
            break;
        default:
            break;
        }
     
        if (mimetype) {
            return mimetype;
        }
     
        switch (extension) {
        case '.x3d':
            // 3D Crossword Plugin
            mimetype = 'application/vnd.hzn-3d-crossword';
            break;
        case '.3gp':
            // 3GP
            mimetype = 'video/3gpp';
            break;
        case '.3g2':
            // 3GP2
            mimetype = 'video/3gpp2';
            break;
        case '.mseq':
            // 3GPP MSEQ File
            mimetype = 'application/vnd.mseq';
            break;
        case '.pwn':
            // 3M Post It Notes
            mimetype = 'application/vnd.3m.post-it-notes';
            break;
        case '.plb':
            // 3rd Generation Partnership Project - Pic Large
            mimetype = 'application/vnd.3gpp.pic-bw-large';
            break;
        case '.psb':
            // 3rd Generation Partnership Project - Pic Small
            mimetype = 'application/vnd.3gpp.pic-bw-small';
            break;
        case '.pvb':
            // 3rd Generation Partnership Project - Pic Var
            mimetype = 'application/vnd.3gpp.pic-bw-var';
            break;
        case '.tcap':
            // 3rd Generation Partnership Project - Transaction Capabilities Application Part
            mimetype = 'application/vnd.3gpp2.tcap';
            break;
        case '.7z':
            // 7-Zip
            mimetype = 'application/x-7z-compressed';
            break;
        case '.abw':
            // AbiWord
            mimetype = 'application/x-abiword';
            break;
        case '.ace':
            // Ace Archive
            mimetype = 'application/x-ace-compressed';
            break;
        case '.acc':
            // Active Content Compression
            mimetype = 'application/vnd.americandynamics.acc';
            break;
        case '.acu':
            // ACU Cobol
            mimetype = 'application/vnd.acucobol';
            break;
        case '.atc':
            // ACU Cobol
            mimetype = 'application/vnd.acucorp';
            break;
        case '.adp':
            // Adaptive differential pulse-code modulation
            mimetype = 'audio/adpcm';
            break;
        case '.aab':
            // Adobe (Macropedia) Authorware - Binary File
            mimetype = 'application/x-authorware-bin';
            break;
        case '.aam':
            // Adobe (Macropedia) Authorware - Map
            mimetype = 'application/x-authorware-map';
            break;
        case '.aas':
            // Adobe (Macropedia) Authorware - Segment File
            mimetype = 'application/x-authorware-seg';
            break;
        case '.air':
            // Adobe AIR Application
            mimetype = 'application/vnd.adobe.air-application-installer-package+zip';
            break;
        case '.swf':
            // Adobe Flash
            mimetype = 'application/x-shockwave-flash';
            break;
        case '.fxp':
            // Adobe Flex Project
            mimetype = 'application/vnd.adobe.fxp';
            break;
        case '.ppd':
            // Adobe PostScript Printer Description File Format
            mimetype = 'application/vnd.cups-ppd';
            break;
        case '.dir':
            // Adobe Shockwave Player
            mimetype = 'application/x-director';
            break;
        case '.xdp':
            // Adobe XML Data Package
            mimetype = 'application/vnd.adobe.xdp+xml';
            break;
        case '.xfdf':
            // Adobe XML Forms Data Format
            mimetype = 'application/vnd.adobe.xfdf';
            break;
        case '.aac':
            // Advanced Audio Coding (AAC)
            mimetype = 'audio/x-aac';
            break;
        case '.ahead':
            // Ahead AIR Application
            mimetype = 'application/vnd.ahead.space';
            break;
        case '.azf':
            // AirZip FileSECURE
            mimetype = 'application/vnd.airzip.filesecure.azf';
            break;
        case '.azs':
            // AirZip FileSECURE
            mimetype = 'application/vnd.airzip.filesecure.azs';
            break;
        case '.azw':
            // Amazon Kindle eBook format
            mimetype = 'application/vnd.amazon.ebook';
            break;
        case '.ami':
            // AmigaDE
            mimetype = 'application/vnd.amiga.ami';
            break;
        case 'N/A':
            // Andrew Toolkit
            mimetype = 'application/andrew-inset';
            break;
        case '.apk':
            // Android Package Archive
            mimetype = 'application/vnd.android.package-archive';
            break;
        case '.cii':
            // ANSER-WEB Terminal Client - Certificate Issue
            mimetype = 'application/vnd.anser-web-certificate-issue-initiation';
            break;
        case '.fti':
            // ANSER-WEB Terminal Client - Web Funds Transfer
            mimetype = 'application/vnd.anser-web-funds-transfer-initiation';
            break;
        case '.atx':
            // Antix Game Player
            mimetype = 'application/vnd.antix.game-component';
            break;
        case '.mpkg':
            // Apple Installer Package
            mimetype = 'application/vnd.apple.installer+xml';
            break;
        case '.aw':
            // Applixware
            mimetype = 'application/applixware';
            break;
        case '.les':
            // Archipelago Lesson Player
            mimetype = 'application/vnd.hhe.lesson-player';
            break;
        case '.swi':
            // Arista Networks Software Image
            mimetype = 'application/vnd.aristanetworks.swi';
            break;
        case '.s':
            // Assembler Source File
            mimetype = 'text/x-asm';
            break;
        case '.atomcat':
            // Atom Publishing Protocol
            mimetype = 'application/atomcat+xml';
            break;
        case '.atomsvc':
            // Atom Publishing Protocol Service Document
            mimetype = 'application/atomsvc+xml';
            break;
        case '.atom, .xml':
            // Atom Syndication Format
            mimetype = 'application/atom+xml';
            break;
        case '.ac':
            // Attribute Certificate
            mimetype = 'application/pkix-attr-cert';
            break;
        case '.aif':
            // Audio Interchange File Format
            mimetype = 'audio/x-aiff';
            break;
        case '.avi':
            // Audio Video Interleave (AVI)
            mimetype = 'video/x-msvideo';
            break;
        case '.aep':
            // Audiograph
            mimetype = 'application/vnd.audiograph';
            break;
        case '.dxf':
            // AutoCAD DXF
            mimetype = 'image/vnd.dxf';
            break;
        case '.dwf':
            // Autodesk Design Web Format (DWF)
            mimetype = 'model/vnd.dwf';
            break;
        case '.par':
            // BAS Partitur Format
            mimetype = 'text/plain-bas';
            break;
        case '.bcpio':
            // Binary CPIO Archive
            mimetype = 'application/x-bcpio';
            break;
        case '.bin':
            // Binary Data
            mimetype = 'application/octet-stream';
            break;
        case '.torrent':
            // BitTorrent
            mimetype = 'application/x-bittorrent';
            break;
        case '.cod':
            // Blackberry COD File
            mimetype = 'application/vnd.rim.cod';
            break;
        case '.bmi':
            // BMI Drawing Data Interchange
            mimetype = 'application/vnd.bmi';
            break;
        case '.sh':
            // Bourne Shell Script
            mimetype = 'application/x-sh';
            break;
        case '.btif':
            // BTIF
            mimetype = 'image/prs.btif';
            break;
        case '.rep':
            // BusinessObjects
            mimetype = 'application/vnd.businessobjects';
            break;
        case '.bz':
            // Bzip Archive
            mimetype = 'application/x-bzip';
            break;
        case '.bz2':
            // Bzip2 Archive
            mimetype = 'application/x-bzip2';
            break;
        case '.csh':
            // C Shell Script
            mimetype = 'application/x-csh';
            break;
        case '.c':
            // C Source File
            mimetype = 'text/x-c';
            break;
        case '.cdxml':
            // CambridgeSoft Chem Draw
            mimetype = 'application/vnd.chemdraw+xml';
            break;
        case '.css':
            // Cascading Style Sheets (CSS)
            mimetype = 'text/css';
            break;
        case '.cdx':
            // ChemDraw eXchange file
            mimetype = 'chemical/x-cdx';
            break;
        case '.cml':
            // Chemical Markup Language
            mimetype = 'chemical/x-cml';
            break;
        case '.csml':
            // Chemical Style Markup Language
            mimetype = 'chemical/x-csml';
            break;
        case '.cdbcmsg':
            // CIM Database
            mimetype = 'application/vnd.contact.cmsg';
            break;
        case '.cla':
            // Claymore Data Files
            mimetype = 'application/vnd.claymore';
            break;
        case '.c4g':
            // Clonk Game
            mimetype = 'application/vnd.clonk.c4group';
            break;
        case '.sub':
            // Close Captioning - Subtitle
            mimetype = 'image/vnd.dvb.subtitle';
            break;
        case '.cdmia':
            // Cloud Data Management Interface (CDMI) - Capability
            mimetype = 'application/cdmi-capability';
            break;
        case '.cdmic':
            // Cloud Data Management Interface (CDMI) - Contaimer
            mimetype = 'application/cdmi-container';
            break;
        case '.cdmid':
            // Cloud Data Management Interface (CDMI) - Domain
            mimetype = 'application/cdmi-domain';
            break;
        case '.cdmio':
            // Cloud Data Management Interface (CDMI) - Object
            mimetype = 'application/cdmi-object';
            break;
        case '.cdmiq':
            // Cloud Data Management Interface (CDMI) - Queue
            mimetype = 'application/cdmi-queue';
            break;
        case '.c11amc':
            // ClueTrust CartoMobile - Config
            mimetype = 'application/vnd.cluetrust.cartomobile-config';
            break;
        case '.c11amz':
            // ClueTrust CartoMobile - Config Package
            mimetype = 'application/vnd.cluetrust.cartomobile-config-pkg';
            break;
        case '.ras':
            // CMU Image
            mimetype = 'image/x-cmu-raster';
            break;
        case '.csv':
            // Comma-Seperated Values
            mimetype = 'text/csv';
            break;
        case '.cpt':
            // Compact Pro
            mimetype = 'application/mac-compactpro';
            break;
        case '.wmlc':
            // Compiled Wireless Markup Language (WMLC)
            mimetype = 'application/vnd.wap.wmlc';
            break;
        case '.cgm':
            // Computer Graphics Metafile
            mimetype = 'image/cgm';
            break;
        case '.ice':
            // CoolTalk
            mimetype = 'x-conference/x-cooltalk';
            break;
        case '.cmx':
            // Corel Metafile Exchange (CMX)
            mimetype = 'image/x-cmx';
            break;
        case '.xar':
            // CorelXARA
            mimetype = 'application/vnd.xara';
            break;
        case '.cmc':
            // CosmoCaller
            mimetype = 'application/vnd.cosmocaller';
            break;
        case '.cpio':
            // CPIO Archive
            mimetype = 'application/x-cpio';
            break;
        case '.clkx':
            // CrickSoftware - Clicker
            mimetype = 'application/vnd.crick.clicker';
            break;
        case '.clkk':
            // CrickSoftware - Clicker - Keyboard
            mimetype = 'application/vnd.crick.clicker.keyboard';
            break;
        case '.clkp':
            // CrickSoftware - Clicker - Palette
            mimetype = 'application/vnd.crick.clicker.palette';
            break;
        case '.clkt':
            // CrickSoftware - Clicker - Template
            mimetype = 'application/vnd.crick.clicker.template';
            break;
        case '.clkw':
            // CrickSoftware - Clicker - Wordbank
            mimetype = 'application/vnd.crick.clicker.wordbank';
            break;
        case '.wbs':
            // Critical Tools - PERT Chart EXPERT
            mimetype = 'application/vnd.criticaltools.wbs+xml';
            break;
        case '.cryptonote':
            // CryptoNote
            mimetype = 'application/vnd.rig.cryptonote';
            break;
        case '.cif':
            // Crystallographic Interchange Format
            mimetype = 'chemical/x-cif';
            break;
        case '.cmdf':
            // CrystalMaker Data Format
            mimetype = 'chemical/x-cmdf';
            break;
        case '.cu':
            // CU-SeeMe
            mimetype = 'application/cu-seeme';
            break;
        case '.cww':
            // CU-Writer
            mimetype = 'application/prs.cww';
            break;
        case '.dcurl':
            // Curl - Detached Applet
            mimetype = 'text/vnd.curl.dcurl';
            break;
        case '.mcurl':
            // Curl - Manifest File
            mimetype = 'text/vnd.curl.mcurl';
            break;
        case '.scurl':
            // Curl - Source Code
            mimetype = 'text/vnd.curl.scurl';
            break;
        case '.car':
            // CURL Applet
            mimetype = 'application/vnd.curl.car';
            break;
        case '.pcurl':
            // CURL Applet
            mimetype = 'application/vnd.curl.pcurl';
            break;
        case '.cmp':
            // CustomMenu
            mimetype = 'application/vnd.yellowriver-custom-menu';
            break;
        case '.dssc':
            // Data Structure for the Security Suitability of Cryptographic Algorithms
            mimetype = 'application/dssc+der';
            break;
        case '.xdssc':
            // Data Structure for the Security Suitability of Cryptographic Algorithms
            mimetype = 'application/dssc+xml';
            break;
        case '.deb':
            // Debian Package
            mimetype = 'application/x-debian-package';
            break;
        case '.uva':
            // DECE Audio
            mimetype = 'audio/vnd.dece.audio';
            break;
        case '.uvi':
            // DECE Graphic
            mimetype = 'image/vnd.dece.graphic';
            break;
        case '.uvh':
            // DECE High Definition Video
            mimetype = 'video/vnd.dece.hd';
            break;
        case '.uvm':
            // DECE Mobile Video
            mimetype = 'video/vnd.dece.mobile';
            break;
        case '.uvu':
            // DECE MP4
            mimetype = 'video/vnd.uvvu.mp4';
            break;
        case '.uvp':
            // DECE PD Video
            mimetype = 'video/vnd.dece.pd';
            break;
        case '.uvs':
            // DECE SD Video
            mimetype = 'video/vnd.dece.sd';
            break;
        case '.uvv':
            // DECE Video
            mimetype = 'video/vnd.dece.video';
            break;
        case '.dvi':
            // Device Independent File Format (DVI)
            mimetype = 'application/x-dvi';
            break;
        case '.seed':
            // Digital Siesmograph Networks - SEED Datafiles
            mimetype = 'application/vnd.fdsn.seed';
            break;
        case '.dtb':
            // Digital Talking Book
            mimetype = 'application/x-dtbook+xml';
            break;
        case '.res':
            // Digital Talking Book - Resource File
            mimetype = 'application/x-dtbresource+xml';
            break;
        case '.ait':
            // Digital Video Broadcasting
            mimetype = 'application/vnd.dvb.ait';
            break;
        case '.svc':
            // Digital Video Broadcasting
            mimetype = 'application/vnd.dvb.service';
            break;
        case '.eol':
            // Digital Winds Music
            mimetype = 'audio/vnd.digital-winds';
            break;
        case '.djvu':
            // DjVu
            mimetype = 'image/vnd.djvu';
            break;
        case '.dtd':
            // Document Type Definition
            mimetype = 'application/xml-dtd';
            break;
        case '.mlp':
            // Dolby Meridian Lossless Packing
            mimetype = 'application/vnd.dolby.mlp';
            break;
        case '.wad':
            // Doom Video Game
            mimetype = 'application/x-doom';
            break;
        case '.dpg':
            // DPGraph
            mimetype = 'application/vnd.dpgraph';
            break;
        case '.dra':
            // DRA Audio
            mimetype = 'audio/vnd.dra';
            break;
        case '.dfac':
            // DreamFactory
            mimetype = 'application/vnd.dreamfactory';
            break;
        case '.dts':
            // DTS Audio
            mimetype = 'audio/vnd.dts';
            break;
        case '.dtshd':
            // DTS High Definition Audio
            mimetype = 'audio/vnd.dts.hd';
            break;
        case '.dwg':
            // DWG Drawing
            mimetype = 'image/vnd.dwg';
            break;
        case '.geo':
            // DynaGeo
            mimetype = 'application/vnd.dynageo';
            break;
        case '.es':
            // ECMAScript
            mimetype = 'application/ecmascript';
            break;
        case '.mag':
            // EcoWin Chart
            mimetype = 'application/vnd.ecowin.chart';
            break;
        case '.mmr':
            // EDMICS 2000
            mimetype = 'image/vnd.fujixerox.edmics-mmr';
            break;
        case '.rlc':
            // EDMICS 2000
            mimetype = 'image/vnd.fujixerox.edmics-rlc';
            break;
        case '.exi':
            // Efficient XML Interchange
            mimetype = 'application/exi';
            break;
        case '.mgz':
            // EFI Proteus
            mimetype = 'application/vnd.proteus.magazine';
            break;
        case '.epub':
            // Electronic Publication
            mimetype = 'application/epub+zip';
            break;
        case '.eml':
            // Email Message
            mimetype = 'message/rfc822';
            break;
        case '.nml':
            // Enliven Viewer
            mimetype = 'application/vnd.enliven';
            break;
        case '.xpr':
            // Express by Infoseek
            mimetype = 'application/vnd.is-xpr';
            break;
        case '.xif':
            // eXtended Image File Format (XIFF)
            mimetype = 'image/vnd.xiff';
            break;
        case '.xfdl':
            // Extensible Forms Description Language
            mimetype = 'application/vnd.xfdl';
            break;
        case '.emma':
            // Extensible MultiModal Annotation
            mimetype = 'application/emma+xml';
            break;
        case '.ez2':
            // EZPix Secure Photo Album
            mimetype = 'application/vnd.ezpix-album';
            break;
        case '.ez3':
            // EZPix Secure Photo Album
            mimetype = 'application/vnd.ezpix-package';
            break;
        case '.fst':
            // FAST Search & Transfer ASA
            mimetype = 'image/vnd.fst';
            break;
        case '.fvt':
            // FAST Search & Transfer ASA
            mimetype = 'video/vnd.fvt';
            break;
        case '.fbs':
            // FastBid Sheet
            mimetype = 'image/vnd.fastbidsheet';
            break;
        case '.fe_launch':
            // FCS Express Layout Link
            mimetype = 'application/vnd.denovo.fcselayout-link';
            break;
        case '.f4v':
            // Flash Video
            mimetype = 'video/x-f4v';
            break;
        case '.flv':
            // Flash Video
            mimetype = 'video/x-flv';
            break;
        case '.fpx':
            // FlashPix
            mimetype = 'image/vnd.fpx';
            break;
        case '.npx':
            // FlashPix
            mimetype = 'image/vnd.net-fpx';
            break;
        case '.flx':
            // FLEXSTOR
            mimetype = 'text/vnd.fmi.flexstor';
            break;
        case '.fli':
            // FLI/FLC Animation Format
            mimetype = 'video/x-fli';
            break;
        case '.ftc':
            // FluxTime Clip
            mimetype = 'application/vnd.fluxtime.clip';
            break;
        case '.fdf':
            // Forms Data Format
            mimetype = 'application/vnd.fdf';
            break;
        case '.f':
            // Fortran Source File
            mimetype = 'text/x-fortran';
            break;
        case '.mif':
            // FrameMaker Interchange Format
            mimetype = 'application/vnd.mif';
            break;
        case '.fm':
            // FrameMaker Normal Format
            mimetype = 'application/vnd.framemaker';
            break;
        case '.fh':
            // FreeHand MX
            mimetype = 'image/x-freehand';
            break;
        case '.fsc':
            // Friendly Software Corporation
            mimetype = 'application/vnd.fsc.weblaunch';
            break;
        case '.fnc':
            // Frogans Player
            mimetype = 'application/vnd.frogans.fnc';
            break;
        case '.ltf':
            // Frogans Player
            mimetype = 'application/vnd.frogans.ltf';
            break;
        case '.ddd':
            // Fujitsu - Xerox 2D CAD Data
            mimetype = 'application/vnd.fujixerox.ddd';
            break;
        case '.xdw':
            // Fujitsu - Xerox DocuWorks
            mimetype = 'application/vnd.fujixerox.docuworks';
            break;
        case '.xbd':
            // Fujitsu - Xerox DocuWorks Binder
            mimetype = 'application/vnd.fujixerox.docuworks.binder';
            break;
        case '.oas':
            // Fujitsu Oasys
            mimetype = 'application/vnd.fujitsu.oasys';
            break;
        case '.oa2':
            // Fujitsu Oasys
            mimetype = 'application/vnd.fujitsu.oasys2';
            break;
        case '.oa3':
            // Fujitsu Oasys
            mimetype = 'application/vnd.fujitsu.oasys3';
            break;
        case '.fg5':
            // Fujitsu Oasys
            mimetype = 'application/vnd.fujitsu.oasysgp';
            break;
        case '.bh2':
            // Fujitsu Oasys
            mimetype = 'application/vnd.fujitsu.oasysprs';
            break;
        case '.spl':
            // FutureSplash Animator
            mimetype = 'application/x-futuresplash';
            break;
        case '.fzs':
            // FuzzySheet
            mimetype = 'application/vnd.fuzzysheet';
            break;
        case '.g3':
            // G3 Fax Image
            mimetype = 'image/g3fax';
            break;
        case '.gmx':
            // GameMaker ActiveX
            mimetype = 'application/vnd.gmx';
            break;
        case '.gtw':
            // Gen-Trix Studio
            mimetype = 'model/vnd.gtw';
            break;
        case '.txd':
            // Genomatix Tuxedo Framework
            mimetype = 'application/vnd.genomatix.tuxedo';
            break;
        case '.ggb':
            // GeoGebra
            mimetype = 'application/vnd.geogebra.file';
            break;
        case '.ggt':
            // GeoGebra
            mimetype = 'application/vnd.geogebra.tool';
            break;
        case '.gdl':
            // Geometric Description Language (GDL)
            mimetype = 'model/vnd.gdl';
            break;
        case '.gex':
            // GeoMetry Explorer
            mimetype = 'application/vnd.geometry-explorer';
            break;
        case '.gxt':
            // GEONExT and JSXGraph
            mimetype = 'application/vnd.geonext';
            break;
        case '.g2w':
            // GeoplanW
            mimetype = 'application/vnd.geoplan';
            break;
        case '.g3w':
            // GeospacW
            mimetype = 'application/vnd.geospace';
            break;
        case '.gsf':
            // Ghostscript Font
            mimetype = 'application/x-font-ghostscript';
            break;
        case '.bdf':
            // Glyph Bitmap Distribution Format
            mimetype = 'application/x-font-bdf';
            break;
        case '.gtar':
            // GNU Tar Files
            mimetype = 'application/x-gtar';
            break;
        case '.texinfo':
            // GNU Texinfo Document
            mimetype = 'application/x-texinfo';
            break;
        case '.gnumeric':
            // Gnumeric
            mimetype = 'application/x-gnumeric';
            break;
        case '.kml':
            // Google Earth - KML
            mimetype = 'application/vnd.google-earth.kml+xml';
            break;
        case '.kmz':
            // Google Earth - Zipped KML
            mimetype = 'application/vnd.google-earth.kmz';
            break;
        case '.gqf':
            // GrafEq
            mimetype = 'application/vnd.grafeq';
            break;
        case '.gv':
            // Graphviz
            mimetype = 'text/vnd.graphviz';
            break;
        case '.gac':
            // Groove - Account
            mimetype = 'application/vnd.groove-account';
            break;
        case '.ghf':
            // Groove - Help
            mimetype = 'application/vnd.groove-help';
            break;
        case '.gim':
            // Groove - Identity Message
            mimetype = 'application/vnd.groove-identity-message';
            break;
        case '.grv':
            // Groove - Injector
            mimetype = 'application/vnd.groove-injector';
            break;
        case '.gtm':
            // Groove - Tool Message
            mimetype = 'application/vnd.groove-tool-message';
            break;
        case '.tpl':
            // Groove - Tool Template
            mimetype = 'application/vnd.groove-tool-template';
            break;
        case '.vcg':
            // Groove - Vcard
            mimetype = 'application/vnd.groove-vcard';
            break;
        case '.h261':
            // H.261
            mimetype = 'video/h261';
            break;
        case '.h263':
            // H.263
            mimetype = 'video/h263';
            break;
        case '.h264':
            // H.264
            mimetype = 'video/h264';
            break;
        case '.hpid':
            // Hewlett Packard Instant Delivery
            mimetype = 'application/vnd.hp-hpid';
            break;
        case '.hps':
            // Hewlett-Packard's WebPrintSmart
            mimetype = 'application/vnd.hp-hps';
            break;
        case '.hdf':
            // Hierarchical Data Format
            mimetype = 'application/x-hdf';
            break;
        case '.rip':
            // Hit'n'Mix
            mimetype = 'audio/vnd.rip';
            break;
        case '.hbci':
            // Homebanking Computer Interface (HBCI)
            mimetype = 'application/vnd.hbci';
            break;
        case '.jlt':
            // HP Indigo Digital Press - Job Layout Languate
            mimetype = 'application/vnd.hp-jlyt';
            break;
        case '.pcl':
            // HP Printer Command Language
            mimetype = 'application/vnd.hp-pcl';
            break;
        case '.hpgl':
            // HP-GL/2 and HP RTL
            mimetype = 'application/vnd.hp-hpgl';
            break;
        case '.hvs':
            // HV Script
            mimetype = 'application/vnd.yamaha.hv-script';
            break;
        case '.hvd':
            // HV Voice Dictionary
            mimetype = 'application/vnd.yamaha.hv-dic';
            break;
        case '.hvp':
            // HV Voice Parameter
            mimetype = 'application/vnd.yamaha.hv-voice';
            break;
        case '.sfd-hdstx':
            // Hydrostatix Master Suite
            mimetype = 'application/vnd.hydrostatix.sof-data';
            break;
        case '.stk':
            // Hyperstudio
            mimetype = 'application/hyperstudio';
            break;
        case '.hal':
            // Hypertext Application Language
            mimetype = 'application/vnd.hal+xml';
            break;
        case '.html':
            // HyperText Markup Language (HTML)
            mimetype = 'text/html';
            break;
        case '.irm':
            // IBM DB2 Rights Manager
            mimetype = 'application/vnd.ibm.rights-management';
            break;
        case '.sc':
            // IBM Electronic Media Management System - Secure Container
            mimetype = 'application/vnd.ibm.secure-container';
            break;
        case '.ics':
            // iCalendar
            mimetype = 'text/calendar';
            break;
        case '.icc':
            // ICC profile
            mimetype = 'application/vnd.iccprofile';
            break;
        case '.ico':
            // Icon Image
            mimetype = 'image/x-icon';
            break;
        case '.igl':
            // igLoader
            mimetype = 'application/vnd.igloader';
            break;
        case '.ief':
            // Image Exchange Format
            mimetype = 'image/ief';
            break;
        case '.ivp':
            // ImmerVision PURE Players
            mimetype = 'application/vnd.immervision-ivp';
            break;
        case '.ivu':
            // ImmerVision PURE Players
            mimetype = 'application/vnd.immervision-ivu';
            break;
        case '.rif':
            // IMS Networks
            mimetype = 'application/reginfo+xml';
            break;
        case '.spot':
            // In3D - 3DML
            mimetype = 'text/vnd.in3d.spot';
            break;
        case '.igs':
            // Initial Graphics Exchange Specification (IGES)
            mimetype = 'model/iges';
            break;
        case '.i2g':
            // Interactive Geometry Software
            mimetype = 'application/vnd.intergeo';
            break;
        case '.cdy':
            // Interactive Geometry Software Cinderella
            mimetype = 'application/vnd.cinderella';
            break;
        case '.xpw':
            // Intercon FormNet
            mimetype = 'application/vnd.intercon.formnet';
            break;
        case '.fcs':
            // International Society for Advancement of Cytometry
            mimetype = 'application/vnd.isac.fcs';
            break;
        case '.ipfix':
            // Internet Protocol Flow Information Export
            mimetype = 'application/ipfix';
            break;
        case '.cer':
            // Internet Public Key Infrastructure - Certificate
            mimetype = 'application/pkix-cert';
            break;
        case '.pki':
            // Internet Public Key Infrastructure - Certificate Management Protocole
            mimetype = 'application/pkixcmp';
            break;
        case '.crl':
            // Internet Public Key Infrastructure - Certificate Revocation Lists
            mimetype = 'application/pkix-crl';
            break;
        case '.pkipath':
            // Internet Public Key Infrastructure - Certification Path
            mimetype = 'application/pkix-pkipath';
            break;
        case '.igm':
            // IOCOM Visimeet
            mimetype = 'application/vnd.insors.igm';
            break;
        case '.rcprofile':
            // IP Unplugged Roaming Client
            mimetype = 'application/vnd.ipunplugged.rcprofile';
            break;
        case '.irp':
            // iRepository / Lucidoc Editor
            mimetype = 'application/vnd.irepository.package+xml';
            break;
        case '.jad':
            // J2ME App Descriptor
            mimetype = 'text/vnd.sun.j2me.app-descriptor';
            break;
        case '.jar':
            // Java Archive
            mimetype = 'application/java-archive';
            break;
        case '.class':
            // Java Bytecode File
            mimetype = 'application/java-vm';
            break;
        case '.jnlp':
            // Java Network Launching Protocol
            mimetype = 'application/x-java-jnlp-file';
            break;
        case '.ser':
            // Java Serialized Object
            mimetype = 'application/java-serialized-object';
            break;
        case '.java':
            // Java Source File
            mimetype = 'text/x-java-source,java';
            break;
        case '.js':
            // JavaScript
            mimetype = 'application/javascript';
            break;
        case '.json':
            // JavaScript Object Notation (JSON)
            mimetype = 'application/json';
            break;
        case '.joda':
            // Joda Archive
            mimetype = 'application/vnd.joost.joda-archive';
            break;
        case '.ktz':
            // Kahootz
            mimetype = 'application/vnd.kahootz';
            break;
        case '.mmd':
            // Karaoke on Chipnuts Chipsets
            mimetype = 'application/vnd.chipnuts.karaoke-mmd';
            break;
        case '.karbon':
            // KDE KOffice Office Suite - Karbon
            mimetype = 'application/vnd.kde.karbon';
            break;
        case '.chrt':
            // KDE KOffice Office Suite - KChart
            mimetype = 'application/vnd.kde.kchart';
            break;
        case '.kfo':
            // KDE KOffice Office Suite - Kformula
            mimetype = 'application/vnd.kde.kformula';
            break;
        case '.flw':
            // KDE KOffice Office Suite - Kivio
            mimetype = 'application/vnd.kde.kivio';
            break;
        case '.kon':
            // KDE KOffice Office Suite - Kontour
            mimetype = 'application/vnd.kde.kontour';
            break;
        case '.kpr':
            // KDE KOffice Office Suite - Kpresenter
            mimetype = 'application/vnd.kde.kpresenter';
            break;
        case '.ksp':
            // KDE KOffice Office Suite - Kspread
            mimetype = 'application/vnd.kde.kspread';
            break;
        case '.kwd':
            // KDE KOffice Office Suite - Kword
            mimetype = 'application/vnd.kde.kword';
            break;
        case '.htke':
            // Kenamea App
            mimetype = 'application/vnd.kenameaapp';
            break;
        case '.kia':
            // Kidspiration
            mimetype = 'application/vnd.kidspiration';
            break;
        case '.kne':
            // Kinar Applications
            mimetype = 'application/vnd.kinar';
            break;
        case '.sse':
            // Kodak Storyshare
            mimetype = 'application/vnd.kodak-descriptor';
            break;
        case '.lasxml':
            // Laser App Enterprise
            mimetype = 'application/vnd.las.las+xml';
            break;
        case '.latex':
            // LaTeX
            mimetype = 'application/x-latex';
            break;
        case '.lbd':
            // Life Balance - Desktop Edition
            mimetype = 'application/vnd.llamagraphics.life-balance.desktop';
            break;
        case '.lbe':
            // Life Balance - Exchange Format
            mimetype = 'application/vnd.llamagraphics.life-balance.exchange+xml';
            break;
        case '.jam':
            // Lightspeed Audio Lab
            mimetype = 'application/vnd.jam';
            break;
        case '.123':
            // Lotus 1-2-3
            mimetype = 'application/vnd.lotus-1-2-3';
            break;
        case '.apr':
            // Lotus Approach
            mimetype = 'application/vnd.lotus-approach';
            break;
        case '.pre':
            // Lotus Freelance
            mimetype = 'application/vnd.lotus-freelance';
            break;
        case '.nsf':
            // Lotus Notes
            mimetype = 'application/vnd.lotus-notes';
            break;
        case '.org':
            // Lotus Organizer
            mimetype = 'application/vnd.lotus-organizer';
            break;
        case '.scm':
            // Lotus Screencam
            mimetype = 'application/vnd.lotus-screencam';
            break;
        case '.lwp':
            // Lotus Wordpro
            mimetype = 'application/vnd.lotus-wordpro';
            break;
        case '.lvp':
            // Lucent Voice
            mimetype = 'audio/vnd.lucent.voice';
            break;
        case '.m3u':
            // M3U (Multimedia Playlist)
            mimetype = 'audio/x-mpegurl';
            break;
        case '.m4v':
            // M4v
            mimetype = 'video/x-m4v';
            break;
        case '.hqx':
            // Macintosh BinHex 4.0
            mimetype = 'application/mac-binhex40';
            break;
        case '.portpkg':
            // MacPorts Port System
            mimetype = 'application/vnd.macports.portpkg';
            break;
        case '.mgp':
            // MapGuide DBXML
            mimetype = 'application/vnd.osgeo.mapguide.package';
            break;
        case '.mrc':
            // MARC Formats
            mimetype = 'application/marc';
            break;
        case '.mrcx':
            // MARC21 XML Schema
            mimetype = 'application/marcxml+xml';
            break;
        case '.mxf':
            // Material Exchange Format
            mimetype = 'application/mxf';
            break;
        case '.nbp':
            // Mathematica Notebook Player
            mimetype = 'application/vnd.wolfram.player';
            break;
        case '.ma':
            // Mathematica Notebooks
            mimetype = 'application/mathematica';
            break;
        case '.mathml':
            // Mathematical Markup Language
            mimetype = 'application/mathml+xml';
            break;
        case '.mbox':
            // Mbox database files
            mimetype = 'application/mbox';
            break;
        case '.mc1':
            // MedCalc
            mimetype = 'application/vnd.medcalcdata';
            break;
        case '.mscml':
            // Media Server Control Markup Language
            mimetype = 'application/mediaservercontrol+xml';
            break;
        case '.cdkey':
            // MediaRemote
            mimetype = 'application/vnd.mediastation.cdkey';
            break;
        case '.mwf':
            // Medical Waveform Encoding Format
            mimetype = 'application/vnd.mfer';
            break;
        case '.mfm':
            // Melody Format for Mobile Platform
            mimetype = 'application/vnd.mfmp';
            break;
        case '.msh':
            // Mesh Data Type
            mimetype = 'model/mesh';
            break;
        case '.mads':
            // Metadata Authority Description Schema
            mimetype = 'application/mads+xml';
            break;
        case '.mets':
            // Metadata Encoding and Transmission Standard
            mimetype = 'application/mets+xml';
            break;
        case '.mods':
            // Metadata Object Description Schema
            mimetype = 'application/mods+xml';
            break;
        case '.meta4':
            // Metalink
            mimetype = 'application/metalink4+xml';
            break;
        case '.potm':
            // Micosoft PowerPoint - Macro-Enabled Template File
            mimetype = 'application/vnd.ms-powerpoint.template.macroenabled.12';
            break;
        case '.docm':
            // Micosoft Word - Macro-Enabled Document
            mimetype = 'application/vnd.ms-word.document.macroenabled.12';
            break;
        case '.dotm':
            // Micosoft Word - Macro-Enabled Template
            mimetype = 'application/vnd.ms-word.template.macroenabled.12';
            break;
        case '.mcd':
            // Micro CADAM Helix D&D
            mimetype = 'application/vnd.mcd';
            break;
        case '.flo':
            // Micrografx
            mimetype = 'application/vnd.micrografx.flo';
            break;
        case '.igx':
            // Micrografx iGrafx Professional
            mimetype = 'application/vnd.micrografx.igx';
            break;
        case '.es3':
            // MICROSEC e-Szign¢
            mimetype = 'application/vnd.eszigno3+xml';
            break;
        case '.asf':
            // Microsoft Advanced Systems Format (ASF)
            mimetype = 'video/x-ms-asf';
            break;
        case '.exe':
            // Microsoft Application
            mimetype = 'application/x-msdownload';
            break;
        case '.cil':
            // Microsoft Artgalry
            mimetype = 'application/vnd.ms-artgalry';
            break;
        case '.cab':
            // Microsoft Cabinet File
            mimetype = 'application/vnd.ms-cab-compressed';
            break;
        case '.ims':
            // Microsoft Class Server
            mimetype = 'application/vnd.ms-ims';
            break;
        case '.application':
            // Microsoft ClickOnce
            mimetype = 'application/x-ms-application';
            break;
        case '.clp':
            // Microsoft Clipboard Clip
            mimetype = 'application/x-msclip';
            break;
        case '.mdi':
            // Microsoft Document Imaging Format
            mimetype = 'image/vnd.ms-modi';
            break;
        case '.eot':
            // Microsoft Embedded OpenType
            mimetype = 'application/vnd.ms-fontobject';
            break;
        case '.chm':
            // Microsoft Html Help File
            mimetype = 'application/vnd.ms-htmlhelp';
            break;
        case '.crd':
            // Microsoft Information Card
            mimetype = 'application/x-mscardfile';
            break;
        case '.lrm':
            // Microsoft Learning Resource Module
            mimetype = 'application/vnd.ms-lrm';
            break;
        case '.mvb':
            // Microsoft MediaView
            mimetype = 'application/x-msmediaview';
            break;
        case '.mny':
            // Microsoft Money
            mimetype = 'application/x-msmoney';
            break;
        case '.obd':
            // Microsoft Office Binder
            mimetype = 'application/x-msbinder';
            break;
        case '.thmx':
            // Microsoft Office System Release Theme
            mimetype = 'application/vnd.ms-officetheme';
            break;
        case '.onetoc':
            // Microsoft OneNote
            mimetype = 'application/onenote';
            break;
        case '.pya':
            // Microsoft PlayReady Ecosystem
            mimetype = 'audio/vnd.ms-playready.media.pya';
            break;
        case '.pyv':
            // Microsoft PlayReady Ecosystem Video
            mimetype = 'video/vnd.ms-playready.media.pyv';
            break;
        case '.pub':
            // Microsoft Publisher
            mimetype = 'application/x-mspublisher';
            break;
        case '.scd':
            // Microsoft Schedule+
            mimetype = 'application/x-msschedule';
            break;
        case '.xap':
            // Microsoft Silverlight
            mimetype = 'application/x-silverlight-app';
            break;
        case '.stl':
            // Microsoft Trust UI Provider - Certificate Trust Link
            mimetype = 'application/vnd.ms-pki.stl';
            break;
        case '.cat':
            // Microsoft Trust UI Provider - Security Catalog
            mimetype = 'application/vnd.ms-pki.seccat';
            break;
        case '.vsd':
            // Microsoft Visio
            mimetype = 'application/vnd.visio';
            break;
        case '.wm':
            // Microsoft Windows Media
            mimetype = 'video/x-ms-wm';
            break;
        case '.wma':
            // Microsoft Windows Media Audio
            mimetype = 'audio/x-ms-wma';
            break;
        case '.wax':
            // Microsoft Windows Media Audio Redirector
            mimetype = 'audio/x-ms-wax';
            break;
        case '.wmx':
            // Microsoft Windows Media Audio/Video Playlist
            mimetype = 'video/x-ms-wmx';
            break;
        case '.wmd':
            // Microsoft Windows Media Player Download Package
            mimetype = 'application/x-ms-wmd';
            break;
        case '.wpl':
            // Microsoft Windows Media Player Playlist
            mimetype = 'application/vnd.ms-wpl';
            break;
        case '.wmz':
            // Microsoft Windows Media Player Skin Package
            mimetype = 'application/x-ms-wmz';
            break;
        case '.wmv':
            // Microsoft Windows Media Video
            mimetype = 'video/x-ms-wmv';
            break;
        case '.wvx':
            // Microsoft Windows Media Video Playlist
            mimetype = 'video/x-ms-wvx';
            break;
        case '.wmf':
            // Microsoft Windows Metafile
            mimetype = 'application/x-msmetafile';
            break;
        case '.trm':
            // Microsoft Windows Terminal Services
            mimetype = 'application/x-msterminal';
            break;
        case '.xbap':
            // Microsoft XAML Browser Application
            mimetype = 'application/x-ms-xbap';
            break;
        case '.xps':
            // Microsoft XML Paper Specification
            mimetype = 'application/vnd.ms-xpsdocument';
            break;
        case '.mid':
            // MIDI - Musical Instrument Digital Interface
            mimetype = 'audio/midi';
            break;
        case '.mpy':
            // MiniPay
            mimetype = 'application/vnd.ibm.minipay';
            break;
        case '.afp':
            // MO:DCA-P
            mimetype = 'application/vnd.ibm.modcap';
            break;
        case '.rms':
            // Mobile Information Device Profile
            mimetype = 'application/vnd.jcp.javame.midlet-rms';
            break;
        case '.tmo':
            // MobileTV
            mimetype = 'application/vnd.tmobile-livetv';
            break;
        case '.prc':
            // Mobipocket
            mimetype = 'application/x-mobipocket-ebook';
            break;
        case '.mbk':
            // Mobius Management Systems - Basket file
            mimetype = 'application/vnd.mobius.mbk';
            break;
        case '.dis':
            // Mobius Management Systems - Distribution Database
            mimetype = 'application/vnd.mobius.dis';
            break;
        case '.plc':
            // Mobius Management Systems - Policy Definition Language File
            mimetype = 'application/vnd.mobius.plc';
            break;
        case '.mqy':
            // Mobius Management Systems - Query File
            mimetype = 'application/vnd.mobius.mqy';
            break;
        case '.msl':
            // Mobius Management Systems - Script Language
            mimetype = 'application/vnd.mobius.msl';
            break;
        case '.txf':
            // Mobius Management Systems - Topic Index File
            mimetype = 'application/vnd.mobius.txf';
            break;
        case '.daf':
            // Mobius Management Systems - UniversalArchive
            mimetype = 'application/vnd.mobius.daf';
            break;
        case '.fly':
            // mod_fly / fly.cgi
            mimetype = 'text/vnd.fly';
            break;
        case '.mpc':
            // Mophun Certificate
            mimetype = 'application/vnd.mophun.certificate';
            break;
        case '.mpn':
            // Mophun VM
            mimetype = 'application/vnd.mophun.application';
            break;
        case '.mj2':
            // Motion JPEG 2000
            mimetype = 'video/mj2';
            break;
        case '.mpga':
            // MPEG Audio
            mimetype = 'audio/mpeg';
            break;
        case '.mxu':
            // MPEG Url
            mimetype = 'video/vnd.mpegurl';
            break;
        case '.mpeg':
            // MPEG Video
            mimetype = 'video/mpeg';
            break;
        case '.m21':
            // MPEG-21
            mimetype = 'application/mp21';
            break;
        case '.mp4a':
            // MPEG-4 Audio
            mimetype = 'audio/mp4';
            break;
        case '.mp4':
            // MPEG-4 Video
            mimetype = 'video/mp4';
            break;
        case '.mp4':
            // MPEG4
            mimetype = 'application/mp4';
            break;
        case '.m3u8':
            // Multimedia Playlist Unicode
            mimetype = 'application/vnd.apple.mpegurl';
            break;
        case '.mus':
            // MUsical Score Interpreted Code Invented for the ASCII designation of Notation
            mimetype = 'application/vnd.musician';
            break;
        case '.msty':
            // Muvee Automatic Video Editing
            mimetype = 'application/vnd.muvee.style';
            break;
        case '.mxml':
            // MXML
            mimetype = 'application/xv+xml';
            break;
        case '.ngdat':
            // N-Gage Game Data
            mimetype = 'application/vnd.nokia.n-gage.data';
            break;
        case '.n-gage':
            // N-Gage Game Installer
            mimetype = 'application/vnd.nokia.n-gage.symbian.install';
            break;
        case '.ncx':
            // Navigation Control file for XML (for ePub)
            mimetype = 'application/x-dtbncx+xml';
            break;
        case '.nc':
            // Network Common Data Form (NetCDF)
            mimetype = 'application/x-netcdf';
            break;
        case '.nlu':
            // neuroLanguage
            mimetype = 'application/vnd.neurolanguage.nlu';
            break;
        case '.dna':
            // New Moon Liftoff/DNA
            mimetype = 'application/vnd.dna';
            break;
        case '.nnd':
            // NobleNet Directory
            mimetype = 'application/vnd.noblenet-directory';
            break;
        case '.nns':
            // NobleNet Sealer
            mimetype = 'application/vnd.noblenet-sealer';
            break;
        case '.nnw':
            // NobleNet Web
            mimetype = 'application/vnd.noblenet-web';
            break;
        case '.rpst':
            // Nokia Radio Application - Preset
            mimetype = 'application/vnd.nokia.radio-preset';
            break;
        case '.rpss':
            // Nokia Radio Application - Preset
            mimetype = 'application/vnd.nokia.radio-presets';
            break;
        case '.n3':
            // Notation3
            mimetype = 'text/n3';
            break;
        case '.edm':
            // Novadigm's RADIA and EDM products
            mimetype = 'application/vnd.novadigm.edm';
            break;
        case '.edx':
            // Novadigm's RADIA and EDM products
            mimetype = 'application/vnd.novadigm.edx';
            break;
        case '.ext':
            // Novadigm's RADIA and EDM products
            mimetype = 'application/vnd.novadigm.ext';
            break;
        case '.gph':
            // NpGraphIt
            mimetype = 'application/vnd.flographit';
            break;
        case '.ecelp4800':
            // Nuera ECELP 4800
            mimetype = 'audio/vnd.nuera.ecelp4800';
            break;
        case '.ecelp7470':
            // Nuera ECELP 7470
            mimetype = 'audio/vnd.nuera.ecelp7470';
            break;
        case '.ecelp9600':
            // Nuera ECELP 9600
            mimetype = 'audio/vnd.nuera.ecelp9600';
            break;
        case '.oda':
            // Office Document Architecture
            mimetype = 'application/oda';
            break;
        case '.ogx':
            // Ogg
            mimetype = 'application/ogg';
            break;
        case '.oga':
            // Ogg Audio
            mimetype = 'audio/ogg';
            break;
        case '.ogv':
            // Ogg Video
            mimetype = 'video/ogg';
            break;
        case '.dd2':
            // OMA Download Agents
            mimetype = 'application/vnd.oma.dd2+xml';
            break;
        case '.oth':
            // Open Document Text Web
            mimetype = 'application/vnd.oasis.opendocument.text-web';
            break;
        case '.opf':
            // Open eBook Publication Structure
            mimetype = 'application/oebps-package+xml';
            break;
        case '.qbo':
            // Open Financial Exchange
            mimetype = 'application/vnd.intu.qbo';
            break;
        case '.oxt':
            // Open Office Extension
            mimetype = 'application/vnd.openofficeorg.extension';
            break;
        case '.osf':
            // Open Score Format
            mimetype = 'application/vnd.yamaha.openscoreformat';
            break;
        case '.weba':
            // Open Web Media Project - Audio
            mimetype = 'audio/webm';
            break;
        case '.webm':
            // Open Web Media Project - Video
            mimetype = 'video/webm';
            break;
        case '.odc':
            // OpenDocument Chart
            mimetype = 'application/vnd.oasis.opendocument.chart';
            break;
        case '.otc':
            // OpenDocument Chart Template
            mimetype = 'application/vnd.oasis.opendocument.chart-template';
            break;
        case '.odb':
            // OpenDocument Database
            mimetype = 'application/vnd.oasis.opendocument.database';
            break;
        case '.odf':
            // OpenDocument Formula
            mimetype = 'application/vnd.oasis.opendocument.formula';
            break;
        case '.odft':
            // OpenDocument Formula Template
            mimetype = 'application/vnd.oasis.opendocument.formula-template';
            break;
        case '.odg':
            // OpenDocument Graphics
            mimetype = 'application/vnd.oasis.opendocument.graphics';
            break;
        case '.otg':
            // OpenDocument Graphics Template
            mimetype = 'application/vnd.oasis.opendocument.graphics-template';
            break;
        case '.odi':
            // OpenDocument Image
            mimetype = 'application/vnd.oasis.opendocument.image';
            break;
        case '.oti':
            // OpenDocument Image Template
            mimetype = 'application/vnd.oasis.opendocument.image-template';
            break;
        case '.odp':
            // OpenDocument Presentation
            mimetype = 'application/vnd.oasis.opendocument.presentation';
            break;
        case '.otp':
            // OpenDocument Presentation Template
            mimetype = 'application/vnd.oasis.opendocument.presentation-template';
            break;
        case '.ods':
            // OpenDocument Spreadsheet
            mimetype = 'application/vnd.oasis.opendocument.spreadsheet';
            break;
        case '.ots':
            // OpenDocument Spreadsheet Template
            mimetype = 'application/vnd.oasis.opendocument.spreadsheet-template';
            break;
        case '.odt':
            // OpenDocument Text
            mimetype = 'application/vnd.oasis.opendocument.text';
            break;
        case '.odm':
            // OpenDocument Text Master
            mimetype = 'application/vnd.oasis.opendocument.text-master';
            break;
        case '.ott':
            // OpenDocument Text Template
            mimetype = 'application/vnd.oasis.opendocument.text-template';
            break;
        case '.ktx':
            // OpenGL Textures (KTX)
            mimetype = 'image/ktx';
            break;
        case '.sxc':
            // OpenOffice - Calc (Spreadsheet)
            mimetype = 'application/vnd.sun.xml.calc';
            break;
        case '.stc':
            // OpenOffice - Calc Template (Spreadsheet)
            mimetype = 'application/vnd.sun.xml.calc.template';
            break;
        case '.sxd':
            // OpenOffice - Draw (Graphics)
            mimetype = 'application/vnd.sun.xml.draw';
            break;
        case '.std':
            // OpenOffice - Draw Template (Graphics)
            mimetype = 'application/vnd.sun.xml.draw.template';
            break;
        case '.sxi':
            // OpenOffice - Impress (Presentation)
            mimetype = 'application/vnd.sun.xml.impress';
            break;
        case '.sti':
            // OpenOffice - Impress Template (Presentation)
            mimetype = 'application/vnd.sun.xml.impress.template';
            break;
        case '.sxm':
            // OpenOffice - Math (Formula)
            mimetype = 'application/vnd.sun.xml.math';
            break;
        case '.sxw':
            // OpenOffice - Writer (Text - HTML)
            mimetype = 'application/vnd.sun.xml.writer';
            break;
        case '.sxg':
            // OpenOffice - Writer (Text - HTML)
            mimetype = 'application/vnd.sun.xml.writer.global';
            break;
        case '.stw':
            // OpenOffice - Writer Template (Text - HTML)
            mimetype = 'application/vnd.sun.xml.writer.template';
            break;
        case '.otf':
            // OpenType Font File
            mimetype = 'application/x-font-otf';
            break;
        case '.osfpvg':
            // OSFPVG
            mimetype = 'application/vnd.yamaha.openscoreformat.osfpvg+xml';
            break;
        case '.dp':
            // OSGi Deployment Package
            mimetype = 'application/vnd.osgi.dp';
            break;
        case '.pdb':
            // PalmOS Data
            mimetype = 'application/vnd.palm';
            break;
        case '.p':
            // Pascal Source File
            mimetype = 'text/x-pascal';
            break;
        case '.paw':
            // PawaaFILE
            mimetype = 'application/vnd.pawaafile';
            break;
        case '.pclxl':
            // PCL 6 Enhanced (Formely PCL XL)
            mimetype = 'application/vnd.hp-pclxl';
            break;
        case '.efif':
            // Pcsel eFIF File
            mimetype = 'application/vnd.picsel';
            break;
        case '.pcx':
            // PCX Image
            mimetype = 'image/x-pcx';
            break;
        case '.psd':
            // Photoshop Document
            mimetype = 'image/vnd.adobe.photoshop';
            break;
        case '.prf':
            // PICSRules
            mimetype = 'application/pics-rules';
            break;
        case '.pic':
            // PICT Image
            mimetype = 'image/x-pict';
            break;
        case '.chat':
            // pIRCh
            mimetype = 'application/x-chat';
            break;
        case '.p10':
            // PKCS #10 - Certification Request Standard
            mimetype = 'application/pkcs10';
            break;
        case '.p12':
            // PKCS #12 - Personal Information Exchange Syntax Standard
            mimetype = 'application/x-pkcs12';
            break;
        case '.p7m':
            // PKCS #7 - Cryptographic Message Syntax Standard
            mimetype = 'application/pkcs7-mime';
            break;
        case '.p7s':
            // PKCS #7 - Cryptographic Message Syntax Standard
            mimetype = 'application/pkcs7-signature';
            break;
        case '.p7r':
            // PKCS #7 - Cryptographic Message Syntax Standard (Certificate Request Response)
            mimetype = 'application/x-pkcs7-certreqresp';
            break;
        case '.p7b':
            // PKCS #7 - Cryptographic Message Syntax Standard (Certificates)
            mimetype = 'application/x-pkcs7-certificates';
            break;
        case '.p8':
            // PKCS #8 - Private-Key Information Syntax Standard
            mimetype = 'application/pkcs8';
            break;
        case '.plf':
            // PocketLearn Viewers
            mimetype = 'application/vnd.pocketlearn';
            break;
        case '.pnm':
            // Portable Anymap Image
            mimetype = 'image/x-portable-anymap';
            break;
        case '.pbm':
            // Portable Bitmap Format
            mimetype = 'image/x-portable-bitmap';
            break;
        case '.pcf':
            // Portable Compiled Format
            mimetype = 'application/x-font-pcf';
            break;
        case '.pfr':
            // Portable Font Resource
            mimetype = 'application/font-tdpfr';
            break;
        case '.pgn':
            // Portable Game Notation (Chess Games)
            mimetype = 'application/x-chess-pgn';
            break;
        case '.pgm':
            // Portable Graymap Format
            mimetype = 'image/x-portable-graymap';
            break;
        case '.pskcxml':
            // Portable Symmetric Key Container
            mimetype = 'application/pskc+xml';
            break;
        case '.pml':
            // PosML
            mimetype = 'application/vnd.ctc-posml';
            break;
        case '.ai':
            // PostScript
            mimetype = 'application/postscript';
            break;
        case '.pfa':
            // PostScript Fonts
            mimetype = 'application/x-font-type1';
            break;
        case '.pbd':
            // PowerBuilder
            mimetype = 'application/vnd.powerbuilder6';
            break;
        case '':
            // Pretty Good Privacy
            mimetype = 'application/pgp-encrypted';
            break;
        case '.pgp':
            // Pretty Good Privacy - Signature
            mimetype = 'application/pgp-signature';
            break;
        case '.box':
            // Preview Systems ZipLock/VBox
            mimetype = 'application/vnd.previewsystems.box';
            break;
        case '.ptid':
            // Princeton Video Image
            mimetype = 'application/vnd.pvi.ptid1';
            break;
        case '.pls':
            // Pronunciation Lexicon Specification
            mimetype = 'application/pls+xml';
            break;
        case '.str':
            // Proprietary P&G Standard Reporting System
            mimetype = 'application/vnd.pg.format';
            break;
        case '.ei6':
            // Proprietary P&G Standard Reporting System
            mimetype = 'application/vnd.pg.osasli';
            break;
        case '.dsc':
            // PRS Lines Tag
            mimetype = 'text/prs.lines.tag';
            break;
        case '.psf':
            // PSF Fonts
            mimetype = 'application/x-font-linux-psf';
            break;
        case '.qps':
            // PubliShare Objects
            mimetype = 'application/vnd.publishare-delta-tree';
            break;
        case '.wg':
            // Qualcomm's Plaza Mobile Internet
            mimetype = 'application/vnd.pmi.widget';
            break;
        case '.qxd':
            // QuarkXpress
            mimetype = 'application/vnd.quark.quarkxpress';
            break;
        case '.esf':
            // QUASS Stream Player
            mimetype = 'application/vnd.epson.esf';
            break;
        case '.msf':
            // QUASS Stream Player
            mimetype = 'application/vnd.epson.msf';
            break;
        case '.ssf':
            // QUASS Stream Player
            mimetype = 'application/vnd.epson.ssf';
            break;
        case '.qam':
            // QuickAnime Player
            mimetype = 'application/vnd.epson.quickanime';
            break;
        case '.qfx':
            // Quicken
            mimetype = 'application/vnd.intu.qfx';
            break;
        case '.qt':
            // Quicktime Video
            mimetype = 'video/quicktime';
            break;
        case '.rar':
            // RAR Archive
            mimetype = 'application/x-rar-compressed';
            break;
        case '.ram':
            // Real Audio Sound
            mimetype = 'audio/x-pn-realaudio';
            break;
        case '.rmp':
            // Real Audio Sound
            mimetype = 'audio/x-pn-realaudio-plugin';
            break;
        case '.rsd':
            // Really Simple Discovery
            mimetype = 'application/rsd+xml';
            break;
        case '.rm':
            // RealMedia
            mimetype = 'application/vnd.rn-realmedia';
            break;
        case '.mxl':
            // Recordare Applications
            mimetype = 'application/vnd.recordare.musicxml';
            break;
        case '.musicxml':
            // Recordare Applications
            mimetype = 'application/vnd.recordare.musicxml+xml';
            break;
        case '.rnc':
            // Relax NG Compact Syntax
            mimetype = 'application/relax-ng-compact-syntax';
            break;
        case '.rdz':
            // RemoteDocs R-Viewer
            mimetype = 'application/vnd.data-vision.rdz';
            break;
        case '.rdf':
            // Resource Description Framework
            mimetype = 'application/rdf+xml';
            break;
        case '.rp9':
            // RetroPlatform Player
            mimetype = 'application/vnd.cloanto.rp9';
            break;
        case '.jisp':
            // RhymBox
            mimetype = 'application/vnd.jisp';
            break;
        case '.rtf':
            // Rich Text Format
            mimetype = 'application/rtf';
            break;
        case '.rtx':
            // Rich Text Format (RTF)
            mimetype = 'text/richtext';
            break;
        case '.link66':
            // ROUTE 66 Location Based Services
            mimetype = 'application/vnd.route66.link66+xml';
            break;
        case '.rss, .xml':
            // RSS - Really Simple Syndication
            mimetype = 'application/rss+xml';
            break;
        case '.shf':
            // S Hexdump Format
            mimetype = 'application/shf+xml';
            break;
        case '.st':
            // SailingTracker
            mimetype = 'application/vnd.sailingtracker.track';
            break;
        case '.sus':
            // ScheduleUs
            mimetype = 'application/vnd.sus-calendar';
            break;
        case '.sru':
            // Search/Retrieve via URL Response Format
            mimetype = 'application/sru+xml';
            break;
        case '.setpay':
            // Secure Electronic Transaction - Payment
            mimetype = 'application/set-payment-initiation';
            break;
        case '.setreg':
            // Secure Electronic Transaction - Registration
            mimetype = 'application/set-registration-initiation';
            break;
        case '.sema':
            // Secured eMail
            mimetype = 'application/vnd.sema';
            break;
        case '.semd':
            // Secured eMail
            mimetype = 'application/vnd.semd';
            break;
        case '.semf':
            // Secured eMail
            mimetype = 'application/vnd.semf';
            break;
        case '.see':
            // SeeMail
            mimetype = 'application/vnd.seemail';
            break;
        case '.snf':
            // Server Normal Format
            mimetype = 'application/x-font-snf';
            break;
        case '.spq':
            // Server-Based Certificate Validation Protocol - Validation Policies - Request
            mimetype = 'application/scvp-vp-request';
            break;
        case '.spp':
            // Server-Based Certificate Validation Protocol - Validation Policies - Response
            mimetype = 'application/scvp-vp-response';
            break;
        case '.scq':
            // Server-Based Certificate Validation Protocol - Validation Request
            mimetype = 'application/scvp-cv-request';
            break;
        case '.scs':
            // Server-Based Certificate Validation Protocol - Validation Response
            mimetype = 'application/scvp-cv-response';
            break;
        case '.sdp':
            // Session Description Protocol
            mimetype = 'application/sdp';
            break;
        case '.etx':
            // Setext
            mimetype = 'text/x-setext';
            break;
        case '.movie':
            // SGI Movie
            mimetype = 'video/x-sgi-movie';
            break;
        case '.ifm':
            // Shana Informed Filler
            mimetype = 'application/vnd.shana.informed.formdata';
            break;
        case '.itp':
            // Shana Informed Filler
            mimetype = 'application/vnd.shana.informed.formtemplate';
     
            break;
        case '.iif':
            // Shana Informed Filler
            mimetype = 'application/vnd.shana.informed.interchange';
            break;
        case '.ipk':
            // Shana Informed Filler
            mimetype = 'application/vnd.shana.informed.package';
            break;
        case '.tfi':
            // Sharing Transaction Fraud Data
            mimetype = 'application/thraud+xml';
            break;
        case '.shar':
            // Shell Archive
            mimetype = 'application/x-shar';
            break;
        case '.rgb':
            // Silicon Graphics RGB Bitmap
            mimetype = 'image/x-rgb';
            break;
        case '.slt':
            // SimpleAnimeLite Player
            mimetype = 'application/vnd.epson.salt';
            break;
        case '.aso':
            // Simply Accounting
            mimetype = 'application/vnd.accpac.simply.aso';
            break;
        case '.imp':
            // Simply Accounting - Data Import
            mimetype = 'application/vnd.accpac.simply.imp';
            break;
        case '.twd':
            // SimTech MindMapper
            mimetype = 'application/vnd.simtech-mindmapper';
            break;
        case '.csp':
            // Sixth Floor Media - CommonSpace
            mimetype = 'application/vnd.commonspace';
            break;
        case '.saf':
            // SMAF Audio
            mimetype = 'application/vnd.yamaha.smaf-audio';
            break;
        case '.mmf':
            // SMAF File
            mimetype = 'application/vnd.smaf';
            break;
        case '.spf':
            // SMAF Phrase
            mimetype = 'application/vnd.yamaha.smaf-phrase';
            break;
        case '.teacher':
            // SMART Technologies Apps
            mimetype = 'application/vnd.smart.teacher';
            break;
        case '.svd':
            // SourceView Document
            mimetype = 'application/vnd.svd';
            break;
        case '.rq':
            // SPARQL - Query
            mimetype = 'application/sparql-query';
            break;
        case '.srx':
            // SPARQL - Results
            mimetype = 'application/sparql-results+xml';
            break;
        case '.gram':
            // Speech Recognition Grammar Specification
            mimetype = 'application/srgs';
            break;
        case '.grxml':
            // Speech Recognition Grammar Specification - XML
            mimetype = 'application/srgs+xml';
            break;
        case '.ssml':
            // Speech Synthesis Markup Language
            mimetype = 'application/ssml+xml';
            break;
        case '.skp':
            // SSEYO Koan Play File
            mimetype = 'application/vnd.koan';
            break;
        case '.sgml':
            // Standard Generalized Markup Language (SGML)
            mimetype = 'text/sgml';
            break;
        case '.sdc':
            // StarOffice - Calc
            mimetype = 'application/vnd.stardivision.calc';
            break;
        case '.sdd':
            // StarOffice - Impress
            mimetype = 'application/vnd.stardivision.impress';
            break;
        case '.sdw':
            // StarOffice - Writer
            mimetype = 'application/vnd.stardivision.writer';
            break;
        case '.sm':
            // StepMania
            mimetype = 'application/vnd.stepmania.stepchart';
            break;
        case '.sit':
            // Stuffit Archive
            mimetype = 'application/x-stuffit';
            break;
        case '.sitx':
            // Stuffit Archive
            mimetype = 'application/x-stuffitx';
            break;
        case '.sdkm':
            // SudokuMagic
            mimetype = 'application/vnd.solent.sdkm+xml';
            break;
        case '.xo':
            // Sugar Linux Application Bundle
            mimetype = 'application/vnd.olpc-sugar';
            break;
        case '.au':
            // Sun Audio - Au file format
            mimetype = 'audio/basic';
            break;
        case '.wqd':
            // SundaHus WQ
            mimetype = 'application/vnd.wqd';
            break;
        case '.sis':
            // Symbian Install Package
            mimetype = 'application/vnd.symbian.install';
            break;
        case '.smi':
            // Synchronized Multimedia Integration Language
            mimetype = 'application/smil+xml';
            break;
        case '.xsm':
            // SyncML
            mimetype = 'application/vnd.syncml+xml';
            break;
        case '.bdm':
            // SyncML - Device Management
            mimetype = 'application/vnd.syncml.dm+wbxml';
            break;
        case '.xdm':
            // SyncML - Device Management
            mimetype = 'application/vnd.syncml.dm+xml';
            break;
        case '.sv4cpio':
            // System V Release 4 CPIO Archive
            mimetype = 'application/x-sv4cpio';
            break;
        case '.sv4crc':
            // System V Release 4 CPIO Checksum Data
            mimetype = 'application/x-sv4crc';
            break;
        case '.sbml':
            // Systems Biology Markup Language
            mimetype = 'application/sbml+xml';
            break;
        case '.tsv':
            // Tab Seperated Values
            mimetype = 'text/tab-separated-values';
            break;
        case '.tao':
            // Tao Intent
            mimetype = 'application/vnd.tao.intent-module-archive';
            break;
        case '.tar':
            // Tar File (Tape Archive)
            mimetype = 'application/x-tar';
            break;
        case '.tcl':
            // Tcl Script
            mimetype = 'application/x-tcl';
            break;
        case '.tex':
            // TeX
            mimetype = 'application/x-tex';
            break;
        case '.tfm':
            // TeX Font Metric
            mimetype = 'application/x-tex-tfm';
            break;
        case '.tei':
            // Text Encoding and Interchange
            mimetype = 'application/tei+xml';
            break;
        case '.dxp':
            // TIBCO Spotfire
            mimetype = 'application/vnd.spotfire.dxp';
            break;
        case '.sfs':
            // TIBCO Spotfire
            mimetype = 'application/vnd.spotfire.sfs';
            break;
        case '.tsd':
            // Time Stamped Data Envelope
            mimetype = 'application/timestamped-data';
            break;
        case '.tpt':
            // TRI Systems Config
            mimetype = 'application/vnd.trid.tpt';
            break;
        case '.mxs':
            // Triscape Map Explorer
            mimetype = 'application/vnd.triscape.mxs';
            break;
        case '.t':
            // troff
            mimetype = 'text/troff';
            break;
        case '.tra':
            // True BASIC
            mimetype = 'application/vnd.trueapp';
            break;
        case '.ttf':
            // TrueType Font
            mimetype = 'application/x-font-ttf';
            break;
        case '.ttl':
            // Turtle (Terse RDF Triple Language)
            mimetype = 'text/turtle';
            break;
        case '.umj':
            // UMAJIN
            mimetype = 'application/vnd.umajin';
            break;
        case '.uoml':
            // Unique Object Markup Language
            mimetype = 'application/vnd.uoml+xml';
            break;
        case '.unityweb':
            // Unity 3d
            mimetype = 'application/vnd.unity';
            break;
        case '.ufd':
            // Universal Forms Description Language
            mimetype = 'application/vnd.ufdl';
            break;
        case '.uri':
            // URI Resolution Services
            mimetype = 'text/uri-list';
            break;
        case '.utz':
            // User Interface Quartz - Theme (Symbian)
            mimetype = 'application/vnd.uiq.theme';
            break;
        case '.ustar':
            // Ustar (Uniform Standard Tape Archive)
            mimetype = 'application/x-ustar';
            break;
        case '.uu':
            // UUEncode
            mimetype = 'text/x-uuencode';
            break;
        case '.vcs':
            // vCalendar
            mimetype = 'text/x-vcalendar';
            break;
        case '.vcf':
            // vCard
            mimetype = 'text/x-vcard';
            break;
        case '.vcd':
            // Video CD
            mimetype = 'application/x-cdlink';
            break;
        case '.vsf':
            // Viewport+
            mimetype = 'application/vnd.vsf';
            break;
        case '.wrl':
            // Virtual Reality Modeling Language
            mimetype = 'model/vrml';
            break;
        case '.vcx':
            // VirtualCatalog
            mimetype = 'application/vnd.vcx';
            break;
        case '.mts':
            // Virtue MTS
            mimetype = 'model/vnd.mts';
            break;
        case '.vtu':
            // Virtue VTU
            mimetype = 'model/vnd.vtu';
            break;
        case '.vis':
            // Visionary
            mimetype = 'application/vnd.visionary';
            break;
        case '.viv':
            // Vivo
            mimetype = 'video/vnd.vivo';
            break;
        case '.ccxml':
            // Voice Browser Call Control
            mimetype = 'application/ccxml+xml,';
            break;
        case '.vxml':
            // VoiceXML
            mimetype = 'application/voicexml+xml';
            break;
        case '.src':
            // WAIS Source
            mimetype = 'application/x-wais-source';
            break;
        case '.wbxml':
            // WAP Binary XML (WBXML)
            mimetype = 'application/vnd.wap.wbxml';
            break;
        case '.wbmp':
            // WAP Bitamp (WBMP)
            mimetype = 'image/vnd.wap.wbmp';
            break;
        case '.wav':
            // Waveform Audio File Format (WAV)
            mimetype = 'audio/x-wav';
            break;
        case '.davmount':
            // Web Distributed Authoring and Versioning
            mimetype = 'application/davmount+xml';
            break;
        case '.woff':
            // Web Open Font Format
            mimetype = 'application/x-font-woff';
            break;
        case '.wspolicy':
            // Web Services Policy
            mimetype = 'application/wspolicy+xml';
            break;
        case '.webp':
            // WebP Image
            mimetype = 'image/webp';
            break;
        case '.wtb':
            // WebTurbo
            mimetype = 'application/vnd.webturbo';
            break;
        case '.wgt':
            // Widget Packaging and XML Configuration
            mimetype = 'application/widget';
            break;
        case '.hlp':
            // WinHelp
            mimetype = 'application/winhlp';
            break;
        case '.wml':
            // Wireless Markup Language (WML)
            mimetype = 'text/vnd.wap.wml';
            break;
        case '.wmls':
            // Wireless Markup Language Script (WMLScript)
            mimetype = 'text/vnd.wap.wmlscript';
            break;
        case '.wmlsc':
            // WMLScript
            mimetype = 'application/vnd.wap.wmlscriptc';
            break;
        case '.wpd':
            // Wordperfect
            mimetype = 'application/vnd.wordperfect';
            break;
        case '.stf':
            // Worldtalk
            mimetype = 'application/vnd.wt.stf';
            break;
        case '.wsdl':
            // WSDL - Web Services Description Language
            mimetype = 'application/wsdl+xml';
            break;
        case '.der':
            // X.509 Certificate
            mimetype = 'application/x-x509-ca-cert';
            break;
        case '.fig':
            // Xfig
            mimetype = 'application/x-xfig';
            break;
        case '.xhtml':
            // XHTML - The Extensible HyperText Markup Language
            mimetype = 'application/xhtml+xml';
            break;
        case '.xml':
            // XML - Extensible Markup Language
            mimetype = 'application/xml';
            break;
        case '.xdf':
            // XML Configuration Access Protocol - XCAP Diff
            mimetype = 'application/xcap-diff+xml';
            break;
        case '.xenc':
            // XML Encryption Syntax and Processing
            mimetype = 'application/xenc+xml';
            break;
        case '.xer':
            // XML Patch Framework
            mimetype = 'application/patch-ops-error+xml';
            break;
        case '.rl':
            // XML Resource Lists
            mimetype = 'application/resource-lists+xml';
            break;
        case '.rs':
            // XML Resource Lists
            mimetype = 'application/rls-services+xml';
            break;
        case '.rld':
            // XML Resource Lists Diff
            mimetype = 'application/resource-lists-diff+xml';
            break;
        case '.xslt':
            // XML Transformations
            mimetype = 'application/xslt+xml';
            break;
        case '.xop':
            // XML-Binary Optimized Packaging
            mimetype = 'application/xop+xml';
            break;
        case '.xpi':
            // XPInstall - Mozilla
            mimetype = 'application/x-xpinstall';
            break;
        case '.xspf':
            // XSPF - XML Shareable Playlist Format
            mimetype = 'application/xspf+xml';
            break;
        case '.xul':
            // XUL - XML User Interface Language
            mimetype = 'application/vnd.mozilla.xul+xml';
            break;
        case '.xyz':
            // XYZ File Format
            mimetype = 'chemical/x-xyz';
            break;
        case '.yaml':
            // YAML Ain't Markup Language / Yet Another Markup Language
            mimetype = 'text/yaml';
            break;
        case '.yang':
            // YANG Data Modeling Language
            mimetype = 'application/yang';
            break;
        case '.yin':
            // YIN (YANG - XML)
            mimetype = 'application/yin+xml';
            break;
        case '.zir':
            // Z.U.L. Geometry
            mimetype = 'application/vnd.zul';
            break;
        case '.zip':
            // Zip Archive
            mimetype = 'application/zip';
            break;
        case '.zmm':
            // ZVUE Media Manager
            mimetype = 'application/vnd.handheld-entertainment+xml';
            break;
        case '.zaz':
            // Zzazz Deck
            mimetype = 'application/vnd.zzazz.deck+xml';
            break;
        default:
            // Binary Data
            mimetype = 'application/octet-stream';
            break;
        }
     
        return mimetype;
    }

    La fonction getTypemine a été récupérée je ne sais plus où sur le net, et elle vraiment, vraiment, très complète, je vais surement la réduire, mais ce n'est pas l'urgence.

    Que penses-tu de cette fonction ?

    En tout cas, encore merci pour toute l'aide que tu m'apporte (et pour ta patience !), ça fait vraiment plaisir de se sentir aider.

  10. #10
    Expert confirmé
    Avatar de Watilin
    Homme Profil pro
    En recherche d'emploi
    Inscrit en
    Juin 2010
    Messages
    3 100
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : En recherche d'emploi

    Informations forums :
    Inscription : Juin 2010
    Messages : 3 100
    Par défaut
    J’avoue que je ne suis pas à l’aise avec les histoires de NAS. Je ne sais pas comment se comportent les navigateurs quand on leur demande d’accéder à une URL comme 192.168.1.14/Rep/Nomfichier.ext, d’autant qu’ici je ne vois pas quel est le protocole : file: ou http: ?

    Dans le code de ton fils, je ne suis pas sûr de comprendre l’intention, car il y a d’abord une requête fetch, qui récupère les données dans la variable data puis file, mais après la variable file n’est utilisée que pour son name (ligne 26) et le reste semble être oublié. Le lien <a> qui sert à déclencher la boîte de dialogue reçoit dans son attribut href la variable dataURL qui est identique à filePath. C’est comme si le fetch n’avait servi à rien.
    La FAQ JavaScript – Les cours JavaScript
    Touche F12 = la console → l’outil indispensable pour développer en JavaScript !

  11. #11
    Membre éprouvé Avatar de Zebulon777
    Homme Profil pro
    Informaticien
    Inscrit en
    Février 2005
    Messages
    1 327
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Informaticien

    Informations forums :
    Inscription : Février 2005
    Messages : 1 327
    Par défaut
    Normalement, sur les NAS, quand on est en mode "serveur", c'est du http, du moins, c'est comme ça que ça fonctionne au bureau et chez moi.
    Avec Synology, on a le choix entre Apache ou nginx (Syno) et ça fonctionne bien.

    Concernant la fonction, je ne sais trop quoi te dire, si ce n'est de la tester, si tu peux et de nous dire ce qui ne va pas ou ce qui peux être amélioré.

    EDIT :
    En tenant compte de tes remarques, il a reprit les choses et a simplifié grandement la fonction.
    En fait, avec tout ce qu'on trouvait sur le net, on était parti sur des trucs compliqués, halambiqué alors que ça ne l'était vraiment pas.

    La nouvelle fonction :
    Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
     
    function downloadTest(filePath)
    {
    	let filename = filePath.substring(filePath.lastIndexOf('/') + 1);
    	console.log(filename);
     
    	let dataURL = filePath;
     
    	let a = document.createElement("a");
    			a.download = filename;
    			a.href = dataURL;
    			document.body.appendChild(a);
    			a.click();
    			document.body.removeChild(a);
    			writeFile(G_FICLOG, "TELECHARGEMENT : " + filePath + " - Status : " + response.status + " OK ", "OUI");
     
    }

  12. #12
    Expert confirmé
    Avatar de Watilin
    Homme Profil pro
    En recherche d'emploi
    Inscrit en
    Juin 2010
    Messages
    3 100
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : En recherche d'emploi

    Informations forums :
    Inscription : Juin 2010
    Messages : 3 100
    Par défaut
    Je vois, donc c’est des serveurs HTTP qui envoient les fichiers. Du coup j’ai une hypothèse : ces serveurs reconnaissent les types de fichiers courants comme texte ou CSV, et envoient les bons en-tête Content-Type ; mais ils ne savent pas quoi envoyer pour les fichiers Excel. Il y a peut-être moyen d’ajouter l’association dans la configuration de ces serveurs.

    La fonction est bien plus simple comme ça Remarque que dans ce cas, le lien <a> envoie une requête HTTP GET classique à l’adresse filePath. Tu peux voir cette requête dans l’onglet réseau de la console, ce qui te permettra notamment d’examiner les en-têtes et de voir si mon hypothèse est bonne ou pas.
    La FAQ JavaScript – Les cours JavaScript
    Touche F12 = la console → l’outil indispensable pour développer en JavaScript !

  13. #13
    Membre éprouvé Avatar de Zebulon777
    Homme Profil pro
    Informaticien
    Inscrit en
    Février 2005
    Messages
    1 327
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Informaticien

    Informations forums :
    Inscription : Février 2005
    Messages : 1 327
    Par défaut
    Voila ce que donne l'onglet réseau de la console.

    Nom : Enr02.png
Affichages : 333
Taille : 98,4 Ko

    Après ce que je constate ce que si on passe \tests\2020_01_01_CDG.XLSX, ça ne fonctionne pas mais que si on met l'adresse IP, ça fonctionne !

    Par contre, je viens de remarqué qu'avec la fonction simplifiée, on ne pouvait plus tester le retour au cas où le fichier n'existe pas, par exemple ; ce qui implique que je doive reprendre la fonction initiale, non simplifiée.

    Tu aurais une solution ?

  14. #14
    Expert confirmé
    Avatar de Watilin
    Homme Profil pro
    En recherche d'emploi
    Inscrit en
    Juin 2010
    Messages
    3 100
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : En recherche d'emploi

    Informations forums :
    Inscription : Juin 2010
    Messages : 3 100
    Par défaut
    Citation Envoyé par Zebulon777 Voir le message
    Voila ce que donne l'onglet réseau de la console.
    Je vois que le document arrive avec le bon type (on aperçoit le début de vnd.openxmlformats-…). Donc, pas besoin de configurer les serveurs a priori.
    Reste à voir si tous les clients se comportent de la même manière en recevant le fichier. D’ailleurs je me demande : tous les postes de l’entreprise ont une configuration identique ? Firefox / Windows comme dans ton exemple ?

    Citation Envoyé par Zebulon777 Voir le message
    Après ce que je constate ce que si on passe \tests\2020_01_01_CDG.XLSX, ça ne fonctionne pas mais que si on met l'adresse IP, ça fonctionne !
    C’est normal : si on ne précise pas le nom d’hôte, le navigateur suppose qu’il doit prendre celui de la page courante, celui qu’on voit dans la barre d’adresse. location.host expose cette valeur également, si jamais tu as besoin de la tester dans tes scripts.

    Citation Envoyé par Zebulon777 Voir le message
    Par contre, je viens de remarqué qu'avec la fonction simplifiée, on ne pouvait plus tester le retour au cas où le fichier n'existe pas, par exemple
    À ce propos, après quelques tests rapides je me suis rendu compte d’un autre truc : si le serveur n’envoie pas d’en-tête Content-Disposition: attachment, le navigateur va simplement suivre le lien, ce qui aura généralement pour conséquence de quitter la page actuelle. C’est un gros inconvénient, on va chercher à l’éviter.

    Je te propose de reprendre le code avec fetch, mais cette fois en utilisant la variable file.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
      ...
     
      let filename = filePath.substring(filePath.lastIndexOf('/') + 1);
      console.log(filename);
      let file = new File([data], filename, metadata);
     
      // crée un objet "blob:"
      let objectURL = URL.createObjectURL(file);
     
      switch (response.status)
      {
        case 200:
          let a = document.createElement("a");
          a.download = file.name;
          a.href = objectURL;
          document.body.appendChild(a);
          a.click();
          document.body.removeChild(a);
     
          setTimeout(() => {
            URL.revokeObjectURL(objectURL); // supprime l’objet "blob:" pour libérer la mémoire
          }, 5*60*1000); // délai arbitraire de 5 min
     
          writeFile(G_FICLOG, "TELECHARGEMENT : " + filePath + " - Status : " + response.status + " - " + response.statusText, "OUI");
          break;
     
          ...
    J’utilise la fonction URL.createObjectURL(). C’est aussi ce que fait la bibli FileSaver.
    Note l’appel à revokeObjectURL après le clic. Il n’est pas forcément nécessaire si la page est quittée (ou rafraîchie) régulièrement ; mais si ton application est du type single-page, l’accumulation d’objets blob: pourrait être un problème. Aussi, j’ai choisi arbitrairement une limite de 5 minutes après laquelle l’objet est nettoyé. Je considère que l’utilisateur ou l’utilisatrice a eu le temps d’enregistrer son fichier en 5 minutes. C’est une solution un peu moche, mais je ne connais aucun moyen de savoir précisément si / quand une action a été faite avec la popup d’enregistrement de fichier, c’est en-dehors du contexte de la page, et donc hors d’atteinte de JavaScript.

    Il y a encore un endroit où ça peut déconner : fetch est soumis à la même same-origin policy que XMLHttpRequest. As-tu pu faire une requête cross-origin et obtenir un fichier ? J’ai peur qu’une telle requête soit bloquée.
    La FAQ JavaScript – Les cours JavaScript
    Touche F12 = la console → l’outil indispensable pour développer en JavaScript !

  15. #15
    Membre éprouvé Avatar de Zebulon777
    Homme Profil pro
    Informaticien
    Inscrit en
    Février 2005
    Messages
    1 327
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Informaticien

    Informations forums :
    Inscription : Février 2005
    Messages : 1 327
    Par défaut
    J'me répète, mais c'est vraiment super d'être aider, merci.

    Voici la dernière mouture de la fonction en prenant en compte tes remarques.

    Code javascript : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
     
    async function downloadTest(filePath)
    {
    	let extension = filePath.substring(filePath.lastIndexOf('.'));
    	let mimetype = getMimetype(extension);
     
    	let response = await fetch(filePath, {method: "POST"});
    	let data = await response.blob();
    	let metadata = {
    	type: mimetype
    	};
     
    	let filename = filePath.substring(filePath.lastIndexOf('/') + 1);
    	console.log(filename);
    	let file = new File([data], filename, metadata);
     
    	let dataURL = URL.createObjectURL(file);
     
     
    	switch (response.status)
    	{
    		case 200:
    			let a = document.createElement("a");
    			a.download = file.name;
    			a.href = dataURL;
    			document.body.appendChild(a);
    			a.click();
    			document.body.removeChild(a);
    			setTimeout(() => 
    			{
    				URL.revokeObjectURL(objectURL); // supprime l’objet "blob:" pour libérer la mémoire
    			}, 5*60*1000); // délai arbitraire de 5 min
    			writeFile(G_FICLOG, "TELECHARGEMENT : " + filePath + " - Status : " + response.status + " OK ", "OUI");
    			break;
     
    		case 404:
    			alert("Le fichier que vous avez demandé n'existe pas, ou le chemin précisé est incorrect ( " + response.url + " ).");
    			console.warn(response);
    			writeFile(G_FICLOG, "TELECHARGEMENT : " + filePath + " - Status : " + response.status, "OUI");
    			break;
     
    		case 405:
    			alert("Problème de droits d'accès.")
    			console.warn(response);
    			writeFile(G_FICLOG, "TELECHARGEMENT : " + filePath + " - Status : " + response.status, "OUI");
    			break;
     
    		default:
    			alert("Erreur - status : " + response.status);
    			console.warn(response);
    			writeFile(G_FICLOG, "TELECHARGEMENT : " + filePath + " - Status : " + response.status, "OUI");
    			break;
    	}
    }

    Tous les postes concernés de l'entreprise ont la même configuration, donc de ce côté là, ça devrait aller.
    Dans les essais que j'ai fait, la page n'est pas quittée.
    Le fenêtre modale d'ouverture / téléchargement s'ouvre, mais la page html ne bouge pas.
    Je ne vois pas comment provoquer une requête cross-origine ?

  16. #16
    Membre éprouvé Avatar de Zebulon777
    Homme Profil pro
    Informaticien
    Inscrit en
    Février 2005
    Messages
    1 327
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Informaticien

    Informations forums :
    Inscription : Février 2005
    Messages : 1 327
    Par défaut
    Je relance la discussion car je suis bien confronté à un problème de cors_origin.

    Pour résumé, l'appli s'exécute sur un nas ip 192.1.1.57 et on veut pouvoir accéder à des fichiers qui se trouve sur un autre nas ip 192.1.1.55.

    Je précise que c'est de l'intranet.

    J'ai donc ce message d'erreur :
    Blocage d’une requête multiorigines (Cross-Origin Request) : la politique « Same Origin » ne permet pas de consulter la ressource distante située sur http://192.1.1.55/nas_acl/Extranet/M...pe/testphh.txt. Raison : l’en-tête CORS « Access-Control-Allow-Origin » est manquant.
    TypeError: NetworkError when attempting to fetch resource.
    Est-ce qu'il y a moyen d'éviter ça ?

    (Le code est celui qui est dans le message juste au-dessus...)

    Merci d'avance...

  17. #17
    Expert confirmé
    Avatar de Watilin
    Homme Profil pro
    En recherche d'emploi
    Inscrit en
    Juin 2010
    Messages
    3 100
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : En recherche d'emploi

    Informations forums :
    Inscription : Juin 2010
    Messages : 3 100
    Par défaut
    Ok, je vois deux façons de régler ce problème.

    On a un problème à trois composants : le client (le navigateur), le serveur hôte de l’application (192.1.1.57) et le serveur tiers (192.1.1.55).
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
      client --.
       |        \
       |         X requête bloquée
       |          \
       v           v
    192.1.1.57      192.1.1.55
    serveur hôte    NAS tiers
    La requête est bloquée par le navigateur, en effet CORS est un mécanisme de sécurité qui se joue côté client.

    Si tu as moyen de configurer le NAS tiers, en particulier ajouter des en-têtes HTTP, alors il suffit d’ajouter un en-tête Access-Control-Allow-Origin (je vais écrire ACAO pour faire court) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Access-Control-Allow-Origin: http://192.1.1.57
    (Remplace http par https si besoin.)
    En langage humain, cette directive signifie que le serveur tiers autorise l’origine 192.1.1.57 à consulter ses ressources. Si le navigateur voit cet en-tête dans la réponse de 192.1.1.55, il autorisera la requête.

    Si l’IP hôte de l’application est susceptible de changer, il faudrait être capable d’envoyer un en-tête ACAO avec une IP variable. Malheureusement ça demande de pouvoir scripter, et je ne sais pas si c’est possible sur un NAS. La spécification de CORS ne permet pas d’autoriser plusieurs origines, pour des raisons que je ne suis pas capable d’expliquer. Il y a une solution bourrin pour contourner le problème, c’est d’autoriser toutes les origines : Access-Control-Allow-Origin: *, ce qui désactive purement et simplement la protection CORS. C’est une solution envisageable s’il n’y a pas de données sensibles sur le NAS.

    L’autre solution, si tu ne peux pas configurer le NAS pour envoyer l’en-tête ACAO, c’est de faire passer la requête par le serveur hôte qui fera office de proxy. Pour ça il te faut un nouveau script PHP sur le serveur hôte, script que nous nommerons par exemple fetchfile.php et auquel nous enverrons des requêtes POST avec un paramètre url contenant l’adresse complète du fichier demandé.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     client
       |
       |
       |
       v
    192.1.1.57              192.1.1.55
    serveur hôte ---------> NAS tiers
                  requête
    C’est plus ou moins simple à mettre en œuvre avec PHP. Le plus basique est d’utiliser file_get_contents, mais on va déjà faire un minimum de filtrage sur l’URL demandée :
    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    <?php
    // script : fetchfile.php
     
    const ALLOWED_HOSTS = [ '192.1.1.55' ];
     
    $unsafe_url = $_POST['url'];
    $url_parts = parse_url($unsafe_url);
     
    if (in_array($url_parts['host'], ALLOWED_HOSTS)) {
        if (!isset($url_parts['path'])) {
            // la partie `path` peut être absente, à toi de voir ce qu’il faut faire dans ce cas
            ...
        }
        else {
            $path = $url_parts['path'];
            $sanitized_url = 'http://' . // remplacer par 'https://' si besoin
                $url_parts['host'] . $path;
     
            header('Content-Disposition: attachment; filename="' . basename($path) . '"');
            echo file_get_contents($sanitized_url);
        }
    }
    Note : realpath() est peut-être intéressante à utiliser ici, mais je ne sais pas comment elle se comporte avec un système de fichiers distant, je ne peux pas tester chez moi. À toi d’essayer

    En l’état, mon code fait un filtrage vraiment minimal en garantissant seulement que la requête ne peut pas être envoyée vers un hôte non autorisé (site de banque, réseau social, etc.). En particulier, le chemin n’est pas normalisé (il peut contenir des ..), je pars du principe qu’il n’y a pas de fichiers sensibles sur le NAS. L’intéret de realpath() est qu’elle normalise les chemins, mais elle a l’inconvénient de ne pas fonctionner quand le fichier n’existe pas. Dans la page de doc, si tu descends, dans les commentaires il y a quelqu’un qui propose une fonction get_absolute_path(), ça peut être utile aussi. Jette un œil

    Pour étoffer un peu notre script, on veut, entre autres, faire passer correctement le Content-Type si le NAS en envoie un au départ. C’est une info qu’on peut obtenir en faisant une requête HEAD, en s’aidant par exemple de la bibliothèque cURL :
    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
            $curl = curl_init($sanitized_url);
            curl_setopt_array($curl, [
              CURLOPT_NOBODY => true, // requête HEAD
              CURLOPT_FAILONERROR => true, // pour debug
            ]);
     
            $success = curl_exec($curl);
     
            $content_type = curl_getinfo($curl, CURLINFO_CONTENT_TYPE);
            if (!is_null($content_type)) {
              header('Content-Type: ' . $content_type);
            }
    Ce code est à placer avant la partie qui fait file_get_contents. cURL te permet aussi te savoir si le fichier demandé existe ou pas, en examinant la valeur de curl_getinfo($curl, CURLINFO_RESPONSE_CODE) qui est un code HTTP classique (200, 404, etc.)

    Comme tu peux le voir cette solution est loin d’être parfaite, il y a des tas de choses à faire à la main. De plus, elle oblige à faire passer tout le contenu du fichier par le serveur hôte, ce qui représente un potentiel point d’étranglement en termes de performance. Donc préfère la première solution si c’est possible
    La FAQ JavaScript – Les cours JavaScript
    Touche F12 = la console → l’outil indispensable pour développer en JavaScript !

  18. #18
    Membre éprouvé Avatar de Zebulon777
    Homme Profil pro
    Informaticien
    Inscrit en
    Février 2005
    Messages
    1 327
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Informaticien

    Informations forums :
    Inscription : Février 2005
    Messages : 1 327
    Par défaut
    Super explication, même si je ne suis pas certain de tout avoir compris.

    Il n'est pas possible de configurer le nas tiers qui est un "vieux" THECUS dont l'interface est plus que rébarbative.

    Je vais donc partir sur les autres solutions.
    Toutefois, je ne comprends pas où je dois insérer ton code dans le mien (je me l'attribue, même si c'est celui de mon fiston ) ?

    Nous n'avons aucun problème de performance car, ça reste de l'intranet (quand nous sommes en 172.xx.xx.xx), mais la plupart du temps, c'est une appli entre quelques bureaux et dans ce cas là, nous sommes en 192.1.1.xx

    En tout cas, encore merci, on va peut-être finir par y arriver.

Discussions similaires

  1. Forcer une page à s'ouvrir avec Internet Explorer
    Par alexbubs dans le forum Balisage (X)HTML et validation W3C
    Réponses: 7
    Dernier message: 31/10/2005, 10h32
  2. Mettre en oeuvre HTTPort
    Par norfelt dans le forum Autres Logiciels
    Réponses: 9
    Dernier message: 20/10/2005, 15h15
  3. Image ouvrir avec
    Par andolini dans le forum Windows
    Réponses: 3
    Dernier message: 02/09/2005, 15h07
  4. Ouvrir avec du menu contextuel
    Par Furius dans le forum Autres Logiciels
    Réponses: 4
    Dernier message: 27/08/2005, 16h03
  5. Mettre null dans un champ avec un domaine de valeur
    Par Kantizbak dans le forum SQL
    Réponses: 7
    Dernier message: 16/02/2005, 09h24

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo