Have ideas to improve npm?Join in the discussion! »

    @shopify/mime-types
    TypeScript icon, indicating that this package has built-in type declarations

    0.2.4 • Public • Published

    @shopify/mime-types

    Build Status Build Status License: MIT npm version npm bundle size (minified + gzip)

    MIME type consistency.

    Installation

    $ yarn add @shopify/mime-types

    Usage

    This package exposes utilities to dynamically get MIME types from file names and/or get file extensions based on common MIME types.

    The types of files currently supported are:

      'image/jpeg',
      'image/png',
      'image/gif',
      'application/pdf',
      'video/mp4',
      'video/quicktime',
      'model/gltf-binary',
      'application/x-mpegURL',
    

    This helps keeping MIME types and file extensions consistent.

    getMimeTypeFromFilename

    Takes in a file name string and returns a MimeType.

    import {getMimeTypeFromFilename} from '@shopify/files';
    
    getMimeTypeFromFilename('image.jpg'); // image/jpeg

    getExtensionFromMimeType

    Takes in a MimeType and returns a string filename extension that matches the inputted MimeType.

    import {getExtensionFromMimeType, MimeType} from '@shopify/files';
    
    getExtensionFromMimeType(MimeType.Pdf); // .pdf

    Keywords

    none

    Install

    npm i @shopify/mime-types

    DownloadsWeekly Downloads

    30,417

    Version

    0.2.4

    License

    MIT

    Unpacked Size

    21.4 kB

    Total Files

    35

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar