2.0.6 • Published 5 years ago
@thewhodidthis/upload v2.0.6
Helps store images on imgur
Setup
# Fetch latest from github
npm i thewhodidthis/upload
# Try example
CLIENT_ID=*** node node_modules/@thewhodidthis/upload/example
Usage
const fs = require('fs')
const upload = require('@thewhodidthis/upload')(process.env.CLIENT_ID)
const uploadCallback = (error, body, { headers }) => {
if (error) {
console.error(error)
} else {
const { data } = JSON.parse(body)
console.log('Result', data)
console.log('Headers', headers)
}
}
fs.readFile(`${__dirname}/my.jpg`, (error, image) => {
if (error) {
return
}
upload(image.toString('base64'), uploadCallback)
})