media-type-detector
Version:
Detects and categorizes media files (image, video, document, etc.) from a Blob using file-type.
20 lines (19 loc) • 864 B
TypeScript
import { MediaCategory, DetectOptions } from './types';
/**
* Fetches a Blob from a URL.
* @param url - The URL of the resource to fetch.
* @returns A Promise that resolves to a Blob.
* @throws Error if the fetch fails or the response is invalid.
*/
export declare function urlToBlob(url: string): Promise<Blob>;
/**
* Detects the category of a file Blob (e.g., image, video, document, etc.)
*/
export declare const detectMediaCategory: (blob: Blob, options?: DetectOptions) => Promise<MediaCategory>;
/**
* Downloads a file from a URL and detects its media category.
* @param url - The file URL.
* @param options - Optional detection settings.
* @returns The detected media category.
*/
export declare const getBlobAndDetectCategory: (url: string, options?: DetectOptions, detectFn?: typeof detectMediaCategory) => Promise<MediaCategory | undefined>;