Socket
Socket
Sign inDemoInstall

imgbb-uploader

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imgbb-uploader

Lightweight module to upload images through Imgbb API.


Version published
Weekly downloads
5.4K
decreased by-37.12%
Maintainers
1
Weekly downloads
 
Created
Source

imgbb-uploader

Lightweight nodejs module to easily upload images through imgbb API

Compatibility:

Node >= 8 recommended ( this module uses async/await )

Install

npm install imgbb-uploader

Use

var imgbbUploader = require('imgbb-uploader');

imgbbUploader("your-imgbb-api-key-string", "home/absolute-path-to-your-image/image.png")
  .then(response => console.log(response))
  .catch(error => console.log(error))

Output example of .then(response => console.log(response)) :

{
  id: '5jKj6XV',
  url_viewer: 'https://ibb.co/5jKj6XV',
  url: 'https://i.ibb.co/94Z4Nmj/test.jpg',
  display_url: 'https://i.ibb.co/94Z4Nmj/test.jpg',
  title: 'test',
  time: '1574431312',
  image: {
    filename: 'test.jpg',
    name: 'test',
    mime: 'image/jpeg',
    extension: 'jpg',
    url: 'https://i.ibb.co/94Z4Nmj/test.jpg',
    size: 91264
  },
  thumb: {
    filename: 'test.jpg',
    name: 'test',
    mime: 'image/jpeg',
    extension: 'jpg',
    url: 'https://i.ibb.co/5jKj6XV/test.jpg',
    size: '12875'
  },
  delete_url: 'https://ibb.co/5jKj6XV/ffd8ef0b1c803f02443553535cf4a5f4'
}

This function returns a promise, this is why console.log(imgbbUploader(myKey, myPath) // output : Promise { <pending> } You access it in your .then(res => res) as shown above.

Learn more

This module doesn't support array uploads and other fancy stuff. For heavy duty uploads, you'll probably have to work with fs.readdir and forEach methods.

In which case you may also be interested in path. For example, you can create a baseDir.js file wherever your images are:

// baseDir.js
const path = require('path');
const dirPath = path.join(__dirname);
module.exports = dirPath;

Then you can require this file elsewhere, and use something like path.join(myDirpath, "subfolder", "subsubfolder") to cross directories programmatically. Once you're there you can fs.readdir and iterate forEach file of that directory, then do whatever you want. That is just a simple example, see fs documentation and Stack Overflow for more inspiration.

Anyway, the module is ~20 lines long & totally unlicensed, so even the most junior Nodejs dev should be able to easily adapt it to its needs.

Keywords

FAQs

Package last updated on 22 Nov 2019

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