1.4.0 • Published 7 months ago

upload-imgbb v1.4.0

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

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.
</details>

---

```javascript
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

1.4.0

7 months ago

1.3.1

7 months ago

1.3.0

7 months ago

1.2.5

7 months ago

1.2.2

7 months ago

1.2.1

7 months ago

1.2.0

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago