2.0.2 • Published 7 years ago
ackee-node-sdk-image-server v2.0.2
Node.js SDK for Resizin
Node.js wrapper around Resizin api.
Import
- Package import and initialization
//when defining all params const upload = require("node-sdk-image-server")('apikey', 'baseurl', 'type'); //simple usage const upload = require("node-sdk-image-server")('apikey');
baseUrlcontains default value which serves resizin production servertypecan beimageorfileand defines whether you will work only with images or with files. Whenfileis selected you can still upload images. Restrictions are only forimagetype.
Upload
- Upload file in code
const fs = require('fs'); const file = fs.createReadStream('/tmp/feedback.pdf'); upload("myId", file, "application/pdf").then(fileDetails => { console.log(fileDetails); });
function takes 3 parameters id of the file file file it self which is stream or buffer and mime-type. If not specified mime-type defaults to application/octet-stream client / browser should provide you with correct mime-type. Or you should know the type of file from somewhere else.
License
Dominik Veselý