postimages-upload
v1.0.3
Published
Library for uploading images to postimages.org, uses Node and Axios. Based on node-upload-images.
Downloads
11
Maintainers
Readme
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.