Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Latest commit

 

History

History

mime-types

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

@shopify/mime-types

Caution

@shopify/mime-types is deprecated.

Shopifolk, see Shopify/quilt-internal for information on the latest packages available for use internally.

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',
  'image/webp',
  'image/heic',
  'image/svg+xml',
  'application/pdf',
  'video/mp4',
  'video/quicktime',
  'video/webm',
  'model/gltf-binary',
  'application/x-mpegURL',
  'model/vnd.usdz+zip',

This helps keeping MIME types and file extensions consistent.

getMimeTypeFromFilename

Takes in a file name string and returns a MimeType.

import {getMimeTypeFromFilename} from '@shopify/mime-types';

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/mime-types';

getExtensionFromMimeType(MimeType.Pdf); // .pdf