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

@muzikanto/file-uploader

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@muzikanto/file-uploader

react file uploader

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

File-Uploader

npm version downloads dependencies Status size

Introduction

Peer dependencies: react, react-dom, @types/react

Installation

npm i @muzikanto/file-uploader
# or
yarn add @muzikanto/file-uploader

Example

Example in storybook

function Component() {
    return (
        <FileUploader
            // files={files}
            // onChange={nextFiles => setFiles(nextFiles)}
            onChange={console.log}
            multiple
            accept={['image/jpeg', 'image/png']}
            maxSize={1024 * 100}
            onErrors={console.log}
            validate={el => el.name.indexOf('.pdf') != -1 ? 'custom error' : undefined}
        >
            {
                ({onClick, files, change, dragged, onDragEnter, onDragLeave, onDragOver, onDrop}) => {
                    return (
                        <>
                            <div
                                style={dragged ? { border: 'dashed 1px black'} : undefined}
                                onClick={onClick}
                                onDragEnter={onDragEnter}
                                onDragOver={onDragOver}
                                onDragLeave={onDragLeave}
                                onDrop={onDrop}
                            >
                                Drag & Drop your files or Browse
                            </div>
                            {
                                files.map(({file, error, success}, i) => {
                                    return (
                                        <>
                                          <span
                                               key={'file-' + i}
                                               style={{backgroundColor: success ? 'green' : 'red'}}
                                           >
                                            {file.name} ({file.size})
                                          </span>  
                                          {
                                              error &&
                                              <span>{error}</span>
                                          }
                                        </>
                                    );
                                })
                            }
                        </>
                    )
                }
            }
        </FileUploader>
    );
}

License

MIT

Keywords

FAQs

Package last updated on 25 Apr 2020

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