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

files-uploader-rc

v3.2.5

Published

Made with create-react-library

Downloads

10

Readme

files-uploader-rc

A very flexible file uploader that comes with: UI showing progress bar of simultaneous (Single or Multiple) file(s) uploading, allows cancel of uploading, flexible to add custom UI drag and drop feature and returns the uploaded file(s) url links. It also comes with its own Hooks incase of when UI is not needed.

NPM JavaScript Style Guide

Install

npm install --save files-uploader-rc

Usage

import React, { Component } from 'react'

import { UploaderUI } from 'files-uploader-rc'
import 'files-uploader-rc/dist/index.css'

class Example extends Component {
  
  const [responseObj, setResponseObj] = React.useState([])

   const getResponseObj = (responseObj) => {
    setResponseObj(responseObj)
  }

  const uri=`this-is-your-remote-server-url-for-the-upload`

  // uriConfig is OPTIONAL: In case of a protected api route for example
   const uriConfig = {
    headers: {
      'x-auth-token': `your-authentication-token`
    }
  }

  console.log(returnUrls) // this is an array of urls of all successfully uploaded files

  render() {
    return (
            <UploaderUI
              allowMultiple
              formDataField={formDataField} 
              getResponseObj={getResponseObj}
              uploadUri={uri}
              uriConfig={uriConfig} // OPTIONAL:   
            />
          )
       }

// allowMultiple to allow multiple file upload default is false.
// formDataField is any name given to the field of formdata while calling thr append method e.g formdata.append(formDataField)
// getResponseObj accepts a callback to update the state of 'responseObj' in  const [responseObj, setResponseObj] = React.useStat([])
// uploadUri this is your remote server url for the upload
// uriConfig is OPTIONAL: In case of a protected api route as stated in the example above.

}

As a Hook

import React, { Component } from 'react'

import { useRcfUploader } from 'files-uploader-rc'


class Example extends Component {
  const uri=`this-is-your-remote-server-url-for-the-upload`

   const [chosenFiles, setChosenFiles] = React.useState([])

   const maxNumOfFiles='max-number-of-files-you-want-to-allow-for-upload'

  const {
    uploading,
    completed,
    onRemoveFile,
    files,
    resObj
   } = useRcfUploader(uri,formDataField,chosenFiles,maxNumOfFiles,uriConfig)

   console.log(responseUrls)


   
   // resObj is an array of response of succesfully uploaded files from the server.
   // uploading indicates uploading is still ongoing this can be used to know when to enable the submit  button
   // completed is when no ongoing uploads
   // uri this is your remote server url for the upload
   // chosenFiles is the initial state of file selected its always an empty array before any file selection.
   // same as value of chosenFiles with some extra property.
   // formDataField is any name given to the field of formdata while calling the append method e.g formdata.append(formDataField)
   // maxNumOfFiles is 5 by default but can be changed.
   // uriConfig is OPTIONAL: In case of a protected api route as stated in the example above.

}

You can also pass your own custom component like below

import React, { Component } from 'react'

import { UploaderUI } from 'files-uploader-rc'
import 'files-uploader-rc/dist/index.css'

class Example extends Component {

  const [responseObj, setResponseObj] = React.useState([])

   const getResponseObj = (responseObj) => {
    setResponseObj(responseObj)
  }

  const uri=`this-is-your-remote-server-url-for-the-upload`

  // uriConfig is OPTIONAL: In case of a protected api route for example
   const uriConfig = {
    headers: {
      'x-auth-token': `your-authentication-token`
    }
  }

  console.log(returnUrls) // this is an array of urls of all successfully uploaded files

  render() {
    return (
            <UploaderUI
              allowMultiple
              formDataField={formDataField} 
              getResponseObj={getResponseObj}
              uploadUri={uri}
              uriConfig={uriConfig} // OPTIONAL:    In case of a protected api route
            >
             <button>Upload files</button>
            </UploaderUI>
          )
       }


// allowMultiple to allow multiple file upload default is false.
// formDataField is any name given to the field of formdata while calling thr append method e.g formdata.append(formDataField)
// getResponseObj accepts a callback to update the state of 'responseObj' in  const [responseObj, setResponseObj] = React.useStat([])
// uploadUri this is your remote server url for the upload
// uriConfig is OPTIONAL: In case of a protected api route as stated in the example above.



}

Screenshot

License