Skip to content

Latest commit

 

History

History
70 lines (46 loc) · 1.49 KB

README.md

File metadata and controls

70 lines (46 loc) · 1.49 KB

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.