imgbb-uploader-api

1.0.2 • Public • Published

imgbb-upload

A simple NPM package for uploading images to ImgBB using different input types (Base64 string, URL, or file path).

Installation

npm install imgbb-uploader-api

Usage

1. Uploading a Base64 Image

const { uploadImage } = require('imgbb-uploader-api');

const apiKey = 'YOUR_CLIENT_API_KEY';
const base64Image = 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';

uploadImage(base64Image, apiKey)
  .then(response => console.log('Image uploaded successfully:', response))
  .catch(error => console.error('Failed to upload image:', error));

2. Uploading an Image from a URL

const { uploadImage } = require('imgbb-uploader-api');

const apiKey = 'YOUR_CLIENT_API_KEY';
const imageUrl = 'https://example.com/image.jpg';

uploadImage(imageUrl, apiKey)
  .then(response => console.log('Image uploaded successfully:', response))
  .catch(error => console.error('Failed to upload image:', error));

3. Uploading an Image from a File Path

const { uploadImage } = require('imgbb-uploader-api');

const apiKey = 'YOUR_CLIENT_API_KEY';
const imagePath = './path/to/image.jpg';

uploadImage(imagePath, apiKey)
  .then(response => console.log('Image uploaded successfully:', response))
  .catch(error => console.error('Failed to upload image:', error));

Options

uploadImage(imageInput, apiKey, expiration)

  • imageInput: (Required) The image input, which can be:

    • A base64-encoded string.
    • A URL to an image.
    • A file path to an image.
  • apiKey: (Required) Your ImgBB API key.

  • expiration: (Optional) The time in seconds for the image to expire. there no expiration in default

Readme

Keywords

none

Package Sidebar

Install

npm i imgbb-uploader-api

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

3.33 kB

Total Files

4

Last publish

Collaborators

  • cynibot