mimalo 0.0.4+5 copy "mimalo: ^0.0.4+5" to clipboard
mimalo: ^0.0.4+5 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';

Examples #

mimalo #

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

String? type = mimalo(filePathOrExtension: "nada.js");

noMeMimes #

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

String? fileExtension = noMeMimes(
  mimeType: "application/javascript",
);
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
110
pub points
24%
popularity

Publisher

unverified uploader

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

Documentation

API reference

License

MIT (LICENSE)

More

Packages that depend on mimalo