Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@uppy/xhr-upload

Package Overview
Dependencies
Maintainers
0
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uppy/xhr-upload

Plain and simple classic HTML multipart form uploads with Uppy, as well as uploads using the HTTP PUT method.


Version published
Weekly downloads
160K
increased by7.29%
Maintainers
0
Weekly downloads
 
Created

What is @uppy/xhr-upload?

@uppy/xhr-upload is a plugin for Uppy, a modular file uploader for web applications. This plugin allows you to upload files using XMLHttpRequest (XHR). It is particularly useful for uploading files to a server endpoint with support for features like progress tracking, aborting uploads, and handling responses.

What are @uppy/xhr-upload's main functionalities?

Basic File Upload

This code demonstrates how to set up a basic file upload using the @uppy/xhr-upload plugin. It initializes Uppy, configures the XHRUpload plugin with an endpoint, and logs a message when the upload is complete.

const Uppy = require('@uppy/core');
const XHRUpload = require('@uppy/xhr-upload');

const uppy = Uppy();

uppy.use(XHRUpload, {
  endpoint: 'https://your-server.com/upload',
  fieldName: 'file'
});

uppy.on('complete', (result) => {
  console.log('Upload complete! We’ve uploaded these files:', result.successful);
});

Progress Tracking

This code demonstrates how to track the progress of file uploads using the @uppy/xhr-upload plugin. It logs the progress of each file being uploaded.

const Uppy = require('@uppy/core');
const XHRUpload = require('@uppy/xhr-upload');

const uppy = Uppy();

uppy.use(XHRUpload, {
  endpoint: 'https://your-server.com/upload',
  fieldName: 'file'
});

uppy.on('upload-progress', (file, progress) => {
  console.log(`File: ${file.name}, Progress: ${progress.bytesUploaded} / ${progress.bytesTotal}`);
});

Aborting Uploads

This code demonstrates how to abort an ongoing file upload using the @uppy/xhr-upload plugin. It starts an upload and then aborts it using the file ID.

const Uppy = require('@uppy/core');
const XHRUpload = require('@uppy/xhr-upload');

const uppy = Uppy();

uppy.use(XHRUpload, {
  endpoint: 'https://your-server.com/upload',
  fieldName: 'file'
});

const fileID = 'some-file-id';
uppy.upload().then((result) => {
  console.log('Upload started');
  uppy.abort(fileID);
  console.log('Upload aborted');
});

Other packages similar to @uppy/xhr-upload

Keywords

FAQs

Package last updated on 27 Jun 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc