npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-resumable-js

v1.1.24

Published

Upload component in React for using with Resumable JS

Downloads

308

Readme

React Resumable JS

Creates an uploader component in React, to use with Resumable JS.

NPM

CircleCI CircleCI

On file added, the upload will begin.

Changelog:

Changelog

Install

npm i react-resumable-js

Options

  • uploaderID The uploader ID. Ex: "image-upload"
  • dropTargetID The dropTarget ID. Ex: "myDropTarget"
  • fileAccept content type file accept on input file Ex: 'image/*'
  • filetypes The allowed files extensions to upload. Ex: "['jpg', 'png']"
  • maxFileSize The allowed file size for upload. Is expressed in bytes. Default is: 10240000 (10mb).
  • onMaxFileSizeErrorCallback Usefull to use with the above param, and take the exception for use as you want.
  • fileAddedMessage The message to print when file is added. Optional. Ex: 'Starting....'
  • completedMessage The message to print when file is completely uploaded. Optional. Ex: 'Completed!'
  • service The service that will receive the file. Ex: 'http://www.someurl.com/myservice/image.json'
  • textLabel The label of the upload. Ex: 'What photo do you want to add?'
  • previousText A Text that will be displayed before the component. Optional.
  • disableDragAndDrop True to disable Drag and Drop. Enable by default.
  • showFileList Show or hide the filelist of uploaded files. accept boolean value
  • onUploadErrorCallback Function to call on Upload error. @returns file and message
  • onFileAddedError Function to call on File Added error. @returns file and errorCount
  • onFileRemoved Function to call on File Removed. @return file object
  • headerObject Optional, if you need to add a headers object.
  • onFileSuccess Method to call when file is upload. Usually a method to set the filename that was uploaded by the component.
  • disableInput Boolean to disable or enable input file. Send true to disable, false otherwise.
  • maxFiles Indicates how many files can be uploaded in a single session. Valid values are any positive integer and undefined for no limit. (Default: undefined)
  • fileNameServer Indicate the fileNameServer Object if the server return an object. Ex {file:"image.jpg"}, so the fileNameServer is "file"
  • tmpDir path to render the preview image on the filelist, if the tmpDir is not set the preview will be a base64encode image ( low performance ). We recommend set the tmpDir
  • chunkSize The size in bytes of each uploaded chunk of data (Default: 110241024)
  • simultaneousUploads Number of simultaneous uploads (Default: 1)
  • fileParameterName The name of the multipart POST parameter to use for the file chunk (Default: file)
  • generateUniqueIdentifier Override the function that generates unique identifiers for each file. (Default: null)
  • maxFilesErrorCallback A function which displays the please upload n file(s) at a time message. (Default: displays an alert box with the message Please n one file(s) at a time.)
  • startButton Boolean value to show the start button
  • pauseButton Boolean value to show the pause button
  • cancelButton Boolean value to show the cancel button
  • forceChunkSize Boolean value to force size of a chunk. (Default: false)

Folders

  • build: last deploy build
  • example: webpack dev server to run the demo
    • server: nodejs server to upload the files
  • src: source code

Example

export default class ExampleForm extends React.Component {

  constructor(props) {
    super(props);
  }

  render() {

      return (
        <fieldset>
          <p>You can add other inputs, selects or stuff right here to complete a form.</p>
          <ReactResumableJs
            uploaderID="image-upload"
            dropTargetID="myDropTarget"
            filetypes={["jpg", "png"]}
            fileAccept="image/*"
            fileAddedMessage="Started!"
            completedMessage="Complete!"
            service="http://localhost:3000/upload"
            textLabel="Uploaded files"
            previousText="Drop to upload your media:"
            disableDragAndDrop={true}
            onFileSuccess={(file, message) => {
              console.log(file, message);
            }}
            onFileAdded={(file, resumable) => {
              resumable.upload();
            }}
            maxFiles={1}
            startButton={true}
            pauseButton={false}
            cancelButton={false}
            onStartUpload={() => {
                console.log("Start upload");
            }}
            onCancelUpload={() => {
                this.inputDisable = false;
            }}
            onPauseUpload={() =>{
                this.inputDisable = false;
            }}
            onResumeUpload={() => {
                this.inputDisable = true;
            }}
          />
        </fieldset>
      );
    }
});

Demo

npm run demo