media-helper.js
function getMimeType (media) {
  return new Promise((resolve, reject) => {
    if (isFile(media)) {
      typechecker.detectFile(media, (err, result) => {
        err && reject(err)
        resolve(result)
      })
    } else if (isBuffer(media)) {
      typechecker.detect(media, (err, result) => {
        err && reject(err)
        resolve(result)
      })
    } else if (isBase64(media)) {
      return getMimeType(toBuffer(media))
    } else if (isURL(media)) {
      return getMimeType(toBuffer(media))
    } else {
      reject('media is not a file')
    }
  })
}
function getMimeType (media) {
  return new Promise((resolve, reject) => {
    if (isFile(media)) {
      typechecker.detectFile(media, (err, result) => {
        err && reject(err)
        resolve(result)
      })
    } else if (isBuffer(media)) {
      typechecker.detect(media, (err, result) => {
        err && reject(err)
        resolve(result)
      })
    } else if (isBase64(media)) {
      return getMimeType(toBuffer(media))
    } else if (isURL(media)) {
      return getMimeType(toBuffer(media))
    } else {
      reject('media is not a file')
    }
  })
}
function getMimeType ( media ) { return new Promise ( ( resolve , reject ) => { if ( isFile ( media ) ) { typechecker . detectFile ( media , ( err , result ) => { err && reject ( err ) resolve ( result ) } ) } else if ( isBuffer ( media ) ) { typechecker . detect ( media , ( err , result ) => { err && reject ( err ) resolve ( result ) } ) } else if ( isBase64 ( media ) ) { return getMimeType ( toBuffer ( media ) ) } else if ( isURL ( media ) ) { return getMimeType ( toBuffer ( media ) ) } else { reject ( 'media is not a file' ) } } ) }
Determines the mime-type of a file
@param {string} media - either path, URL or base64 datas.
@returns {Promise}
Determines the mime - type of a file