mimalo 0.0.3+4 icon indicating copy to clipboard operation
mimalo: ^0.0.3+4 copied to clipboard

A library to get the Mime Types from Extensions and the Extensions from Mime types

Mímalo #

A library to get the Mime Types from Extensions and the Extensions from Mime types

Hecho en 🇵🇷 por Radamés J. Valentín Reyes

Import #

import 'package:mimalo/mimalo.dart';
import 'dart:io';

Examples #

mimalo #

a function to get the mime type of the file by supplying the file path or extension as String

ContentType? type = mimalo(filePathOrExtension: "mimamamemima.js");
if(type != null){
  print(type.mimeType.toString());
}

noMeMimes #

a function to get the extension of the file by supplying the mime type

ContentType? type = mimalo(filePathOrExtension: "nada.js");
String? fileExtension = noMeMimes(
  contentType: type!,
);
if(fileExtension != null){
  print(fileExtension);
}

For node.js users #

A software similar to this(the original library/package) that I wrote a couple of years ago

https://www.npmjs.com/package/mimalo

JS code used to extract mime types from the MDN website #

Ran this code on the developer console while on the MDN website on MIME Types. It was not a perfect solution but only required minimal modification. Just copied the code logged into the console.

var rows = document.getElementById("mimes").getElementsByTagName("tr");
var result = "";
for(rowIndex = 0; rowIndex < rows.length; rowIndex++){
  var thisRow = rows.item(rowIndex);
  var thisColumns = thisRow.getElementsByTagName("td");
  //Extensions are in the first column
  var extensions = thisColumns[0].getElementsByTagName("code");
  var mimeType = thisColumns[2].getElementsByTagName("code")[0].textContent;
  for(extensionIndex = 0; extensionIndex < extensions.length; extensionIndex++){
    var thisExtension = extensions[extensionIndex].textContent;
    result += '"'+ thisExtension +'" : "' + mimeType + '",\n';
  }
}
console.log(result);

Contribute/donate by tapping on the Pay Pal logo/image #


Created by #


References #

0
likes
100
pub points
4%
popularity

Publisher

unverified uploader

A library to get the Mime Types from Extensions and the Extensions from Mime types

Documentation

API reference

License

Icon for licenses.MIT (LICENSE)

More

Packages that depend on mimalo