1.0.0 • Published 8 months ago

base64-blob-converter v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

Base64 to Blob Converter

A TypeScript library to convert base64 strings to Blob URLs or File objects.

Installation

npm install base64-blob-converter

Usage

// ESM
import { Base64Converter } from 'base64-blob-converter';

// CommonJS
const { Base64Converter } = require('base64-blob-converter');

const converter = new Base64Converter();

// Convert to Blob
const blob = converter.toBlob(base64String, 'image/png');

// Convert to Blob URL
const url = converter.toBlobURL(base64String, 'image/png');

// Convert to File
const file = converter.toFile(base64String, {
  filename: 'image.png',
  mimeType: 'image/png'
});

API

toBlob(base64: string, mimeType?: string): Blob

Converts base64 string to a Blob object.

toBlobURL(base64: string, mimeType?: string): string

Converts base64 string to a Blob URL.

toFile(base64: string, options?: ConversionOptions): File

Converts base64 string to a File object.

ConversionOptions

interface ConversionOptions {
  filename?: string;
  mimeType?: string;
}

Restrictions

This library is not available for Gmail users.

1.0.0

8 months ago