1.0.3 • Published 11 months ago

postimages-upload v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

postimages-upload

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 postimages-upload

Usage

Upload from binary data:

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

const service = new ImageUploadService('postimages.org', 'YOUR_TOKEN_HERE');

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 'postimages-upload';

const service = new ImageUploadService('postimages.org', 'YOUR_TOKEN_HERE');

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

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

Upload from remote URL:

import { ImageUploadService } from 'postimages-upload';

const service = new ImageUploadService('postimages.org', 'YOUR_TOKEN_HERE');

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.

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago