Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

@sid-max1996/upload

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sid-max1996/upload

Node js file upload package.

latest
Source
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

@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({
  // byteLimit: 500, // bytes per second limit for download
  // proxyAgent: ProxyAgent('http://51.91.157.66:80'), // to use proxy
  uploadDir, // path to the folder where files are uploaded
  // continueUploading: true, // continue downloading from where it stopped
  // headers: { 'User-Agent': 'App' },
  // timeoutMs: 5000
});
// uploader.emitter.on('debug', text => console.log(text));
uploader.emitter.on('log', (text) => console.log(text));
// tracking download progress
uploader.emitter.on('progress', (value) => console.log(`Progress (value: ${value}).`));

async function start() {
  const filePath = await uploader.upload({
    url,
    // uploadDir: __dirname, // change uploaded file dir
    // fileName: 'hello.jpg', // change uploaded file name
    // filePath: path.join(uploadDir, 'hello1.jpg'), // change uploaded file path
    // continueUploading: true, // change continue downloading from where it stopped
    // headers: { 'User-Agent': 'App' }
  });
  console.log(`Uploaded (path: ${filePath}).`);
  uploader.emitter.removeAllListeners(); // remove all event subscriptions
}

start();

Keywords

upload

FAQs

Package last updated on 20 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts