Socket
Book a DemoInstallSign in
Socket

imsave

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imsave

Imgur image upload

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

imsave

Imgur image upload for node.js and the browser (via browserify).

Build Status Dependency Status NPM version

Installation

To install, use:

npm install imsave

You must then also acquire a ClientID from https://api.imgur.com/oauth2/addclient

Sever Usage

var imgur = require('imsave')('ClientID')

imgur(fs.readFileSync('image.jpeg'), function (err, url) {
  if (err) throw err
  console.log('URL for image: ' + url)
})

//or

imgur(fs.createReadStream('image.jpeg'), function (err, url) {
  if (err) throw err
  console.log('URL for image: ' + url)
})

Client Usage

Using Browserify

<input id="pictureIn" type="file" />
<img id="pictureOut"/>
<button id="submit">Upload</button>
var imgur = require('imsave')('ClientID')

var submit = document.getElementById('submit')
var input = document.getElementById('pictureIn')
var output = document.getElementById('pictureOut')

submit.addEventListener('click', function () {
  imgur(input.files[0], function (err, res) {
    if (err) throw err //handle error here
    output.src = res
  })
}, false)

Promises

If the callback is omitted, a Promises/A+ promise is returned. This is very useful for composing multiple asynchronous operations, especially if they are in parallel.

License

MIT

FAQs

Package last updated on 28 Jun 2013

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