@trevorblades/multer-storage-imgur

1.1.3 • Public • Published

@trevorblades/multer-storage-imgur

Build Status

Easily upload images to Imgur using Multer!

Installation

$ npm install @trevorblades/multer-storage-imgur

Usage

const ImgurStorage = require('@trevorblades/multer-storage-imgur');
const multer = require('multer');

const upload = multer({
  storage: ImgurStorage({
    clientId: 'YOUR_IMGUR_CLIENT_ID'
  })
});

I would recommend storing your Imgur client ID in an environment variable and then load it using dotenv or something similar.

After the file is uploaded to Imgur, the JSON reponse from Imgur will be appended to the file object like this:

{
  ...rest,
  file: {
    fieldname: 'img',
    originalname: 'img2.jpg',
    encoding: '7bit',
    mimetype: 'image/jpeg',
    data: { 
      id: 'LnMoaHr',
      title: null,
      description: null,
      datetime: 1493549597,
      type: 'image/jpeg',
      animated: false,
      width: 564,
      height: 423,
      size: 9767,
      views: 0,
      bandwidth: 0,
      vote: null,
      favorite: false,
      nsfw: null,
      section: null,
      account_url: null,
      account_id: 0,
      is_ad: false,
      tags: [],
      in_most_viral: false,
      in_gallery: false,
      deletehash: 'XBizK4Enq1n7Fze',
      name: '',
      link: 'http://i.imgur.com/LnMoaHr.jpg'
    },
    success: true,
    status: 200
  }
}

/@trevorblades/multer-storage-imgur/

    Package Sidebar

    Install

    npm i @trevorblades/multer-storage-imgur

    Weekly Downloads

    5

    Version

    1.1.3

    License

    MIT

    Unpacked Size

    180 kB

    Total Files

    10

    Last publish

    Collaborators

    • trevorblades