New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

media-helper

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

media-helper

A small module to help detecting and converting files through URL/file sytem

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

media-helper

Installation

npm install media-helper

Usage

var med = require('media-helper')

var path = "/path/to/an/image/"
var url = "http://somesite.com/img.jpg"

if (med.isFile(path) === true ) {
    console.log(path, " is an existing file !")
}
if (med.isURL(url) === true) {
    console.log(url, " is an URL !")
}

var base64_path, base64_url
// This function returns a Promise
med.toBase64(path).then(data => {
    base64_path = data
})
med.toBase64(url).then(data => {
    base64_url = data
})

API

isBase64 (str): Determines if a string is base64 encoded. Returns boolean.

isFile (path): Determines if a string describes a path to an existing file on your system. Returns boolean.

isURL (url): Determines if a string describes an URL. Returns boolean.

getMimeType (path): Determines the mime-type of a file on your system. Uses Promise.

isImage (path): Determines if a file is an image. Uses Promise.

isVideo (path): Determines if a file is a video. Uses Promise.

toBase64 (str): Converts an image to base64, the str parameter can describe either a path or an url. Uses Promise.

urlToBase64 (url): Converts an image to base64 through an URL. Uses Promise.

fileToBase64 (path): Converts an image on your system to base64. Uses Promise

Keywords

FAQs

Package last updated on 05 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc