Skip to content
pubscout

mime2extension

0.0.5, released 8 months ago by uditswaroopa.tech

Convert between MIME types and file extensions and detect file types from base64 data.

WASM-ready
$ flutter pub add mime2extension
Source repository

What it does

Provides bidirectional conversion between MIME types and file extensions with wildcard support. It also detects file extensions and MIME types from base64-encoded binary data using magic bytes and container inspection.

AI-written summary of version 0.0.5, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to resolve file extensions to MIME types or vice versa.
  • You need to determine a file type from base64 string data or data URIs.
  • You want wildcard lookups for broad file categories like image/*.

Skip it when

  • You need direct file system path manipulation utilities.
  • You are reading files directly from disk streams instead of handling strings/base64.

Strengths

  • Comprehensive database of MIME types and over 400 file signatures.
  • Supports wildcards for category-based extension queries.
  • Zero external dependencies except the Flutter SDK.

Weaknesses

  • Limited to string and base64 inputs rather than direct binary stream parsing.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0
import 'package:mime2extension/mime2extension.dart';

String? mimeType = extension2Mime('pdf');
List<String> pdfExts = mime2Extension(['application/pdf']);
String? ext = base64ToExtension('iVBORw0KGgo...');

Alternatives

Packages that do the same job and could replace mime2extension.

  • mime

    Utilities to resolve MIME types from file names, magic bytes, and to parse multipart streams.

  • byte_extensions

    Extensions to convert int, double, BigInt and strings to/from byte arrays with endianness control

  • mime_type

    Library to map file names or extensions to MIME types and vice versa

  • result_type

    A Result type representing success or failure in Dart