Skip to content

Library for uploading images to popular image hosting services, uses Node and Axios.

License

Notifications You must be signed in to change notification settings

4miners/node-upload-images

Repository files navigation

node-upload-images

Library for uploading images to popular image hosting services, uses Node and Axios.

  • Upload from binary, file and remote URL

Supported services

Installation

npm install node-upload-images

Usage

Upload from binary data:

import { ImageUploadService } from 'node-upload-images';
import * as fs from 'fs';

const service = new ImageUploadService('new.fastpic.org');

try {
  const imageData = fs.readFileSync('/test.png');
  let { directLink } = await service.uploadFromBinary(imageData, 'test.png');

  console.log(directLink);
} catch (error) {}

Upload from file:

import { ImageUploadService } from 'node-upload-images';

const service = new ImageUploadService('new.fastpic.org');

try {
  let { directLink } = await service.uploadFromUrl('./test.png');

  console.log(directLink);
} catch (error) {}

Upload from remote URL:

import { ImageUploadService } from 'node-upload-images';

const service = new ImageUploadService('new.fastpic.org');

try {
  let { directLink } = await service.uploadFromUrl(
    'https://example.com/image.png'
  );

  console.log(directLink);
} catch (error) {}

Limitations

No login/authentication support yet, image upload is anonymous.

About

Library for uploading images to popular image hosting services, uses Node and Axios.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published