oro-mimetype
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Oro Mimetype

Class OroMimetype is a wrapper of mmmagic to simplify their use.

mmmagic is a module for node.js that check the file mimetype by their content (not the extension).

npm install oro-mimetype

Examples:

const OMimetype = require( 'oro-mimetype' );

const response = await OMimeType.GetFromFilepath( 'image.png' );
// { status: true, filepath: 'image.png', mimetype: 'image/png' }

const response2 = await OMimeType.GetFromFilepath( 'file.pdf' );
// { status: true, filepath: 'file.pdf', mimetype: 'application/pdf' }

const response3 = await OMimeType.GetFromFilepath( 'file-not-exist.pdf' );
// { 
//   status: false, 
//   filepath: 'file-not-exist.pdf', 
//   msg: "Error: File not exists: 'file-not-exist.pdf'"
// }

const isImage = await OMimeType.IsImage( 'image.png' );
// { status: true, filepath: 'image.png', mimetype: 'image/png' }

const isImage2 = await OMimeType.IsImage( 'file.pdf' );
// { 
//   status: false, 
//   filepath: 'file.pdf', 
//   mimetype: 'application/pdf', 
//   failed: 'image', 
//   msg: "Error: File is not image: 'file.pdf'" 
// }

Methods

// TODO pending to be written 

Package Sidebar

Install

npm i oro-mimetype

Weekly Downloads

12

Version

1.1.0

License

MIT

Unpacked Size

18.5 kB

Total Files

6

Last publish

Collaborators

  • oropesa