@appsemble/utils
Version:
Utility functions used in Appsemble internally
30 lines (29 loc) • 1.18 kB
TypeScript
import { type IconName } from '@fortawesome/fontawesome-common-types';
export declare enum MimeTypeCategory {
Image = "image",
Video = "video",
PDF = "pdf",
Wordprocessing = "wordprocessing",
Spreadsheet = "spreadsheet",
Presentation = "presentation",
Archive = "archive"
}
/**
* Puts a mimetype into one of the predefined categories.
*
* Wildcard behavior is supported.
*
* @param mimeType A mimetype to categorize
* @returns A category that the mimetype falls into or null if no category is found
*/
export declare function getMimeTypeCategory(mimeType: string): MimeTypeCategory | null;
export declare function getMimeTypeCategories(mimeTypes: string[]): (MimeTypeCategory | null)[];
export type FileIconName = IconName | `file-${string}`;
export declare function getMimeTypeIcon(category: MimeTypeCategory | null): FileIconName;
/**
* Extracts the filename from a Content-Disposition header string.
*
* @param contentDisposition The Content-Disposition header string
* @returns The name of the file or null if it's not present
*/
export declare function getFilenameFromContentDisposition(contentDisposition: string): string | null;