upload-imgbb

1.4.0 • Public • Published
Deprecated Upload Function (uploadLink)
const { uploadLink } = require('upload-imgbb');

async function uploadImage(link) {
  try {
    const uploadedLink = await uploadLink(link);
    console.log('Uploaded image link:', uploadedLink);
  } catch (error) {
    console.error('Error uploading image:', error.message);
  }
}

uploadImage('https://example.com/image.jpg');

Note: Replace 'https://example.com/image.jpg' with the actual URL of the image you want to upload.


const { upload } = require('upload-imgbb'); // Updated import for new function

// Example usage of the updated upload function
async function uploadImage(imageStreamOrLink) {
  try {
    const uploadedData = await upload(imageStreamOrLink);
    console.log('Uploaded image data:', uploadedData);
  } catch (error) {
    console.error('Error uploading image:', error.message);
  }
}

// Call the function with either the image stream or the image link
uploadImage('https://example.com/image.jpg'); // Image link example
// or
// uploadImage(imageReadStream); // Image stream example

Parameters

  • imageStreamOrLink (string or stream): Either the URL of the image you want to upload or a readable stream of the image file.
  • json (optional, boolean): Set this parameter to true if you want to receive the response data as a JSON object. By default, it returns the uploaded image URL.

Return Value

The function returns the uploaded image URL by default or the entire response data as a JSON object if the json parameter is set to true.

Important: This updated upload function supports both image streams and image links, providing more flexibility for uploading media files.# upload-imgbb

upload-imgbb

Readme

Keywords

none

Package Sidebar

Install

npm i upload-imgbb

Weekly Downloads

9

Version

1.4.0

License

MIT

Unpacked Size

2.89 MB

Total Files

26

Last publish

Collaborators

  • jsusbinsus