@sid-max1996/upload
Usage
Node js file upload package with the ability to limit the download speed, tracking download progress and continue downloading from where it stopped.
Example
const { Uploader } = require('@sid-max1996/upload');
const fs = require('fs');
const path = require('path');
const ProxyAgent = require('proxy-agent');
const url = 'https://klike.net/uploads/posts/2019-07/1564314090_3.jpg';
const uploadDir = path.join(__dirname, 'download');
if (!fs.existsSync(uploadDir)) {
fs.mkdirSync(uploadDir);
}
const uploader = new Uploader({
uploadDir,
});
uploader.emitter.on('log', (text) => console.log(text));
uploader.emitter.on('progress', (value) => console.log(`Progress (value: ${value}).`));
async function start() {
const filePath = await uploader.upload({
url,
});
console.log(`Uploaded (path: ${filePath}).`);
uploader.emitter.removeAllListeners();
}
start();