New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@j-lamberts/react-file-upload

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@j-lamberts/react-file-upload

File uploader for react.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-file-uploads

[![CircleCI](https://img.shields.io/circleci/project/github/JohannesLamberts/react-file-uploads/master.svg)](https://circleci.com/gh/JohannesLamberts/react-file-uploads)

Features

This packages provides some easy-to-use react components for file uploads. It contains

  • FileUploader to manage all uploads
  • FileDropzone as a simple dropzone wrapper-component
  • FileSelect as a simple wrapper around <input type="file" />

Example

Full-auto

import {
    Button,
    Icon,
    LinearProgress
}                                 from 'material-ui';
import * as React                 from 'react';
import {
    FileDropzone,
    FileSelect,
    FileUploader
}                                 from 'react-file-uploads';

export default () => (
    <FileUploader
        keepOnFinish={true}
        url={'http://localhost:4005/files'}
    >
        {({ handleFiles, queue }) => (
            <div>
                <FileDropzone onDrop={handleFiles}>
                    {queue.map((el, index) => (
                        <div key={index}>
                            {index} {el.name}
                            <LinearProgress
                                variant={el.progressTotal
                                    ? 'determinate'
                                    : 'indeterminate'}
                                value={el.progressLoaded / el.progressTotal * 100}
                            />
                        </div>
                    ))}
                    DROP FILES HERE
                </FileDropzone>
                <div>
                    Uploaded: {queue.length} <br/>
                    Waiting: {queue.filter(el => !el.ready).length}<br/>
                    Ready: {queue.filter(el => el.ready).length}
                </div>
                <FileSelect
                    onChange={handleFiles}
                    multiple={true}
                >
                    <Icon>file_upload</Icon>Upload
                </FileSelect>
            </div>
        )}
    </FileUploader>
);

Manual run()

import {
    Button,
    Icon,
    LinearProgress
}                                 from 'material-ui';
import * as React                 from 'react';
import {
    FileDropzone,
    FileSelect,
    FileUploader
}                                 from 'react-file-uploads';

export default () => (
    <FileUploader
        runManual={true}
        keepOnFinish={true}
        url={'http://localhost:4005/files'}
    >
        {({ handleFiles, queue, runManual }) => (
            <div>
                <!--- as above -->
                <Button onClick={runManual}>
                    <Icon>check</Icon> Run
                </Button>
            </div>
        )}
    </FileUploader>
);

Components

FileUploader

NameTypeDefaultDescription
url *string(required)HTTP-URL
children *(props: FileUploaderChildrenProps) => React.ReactNode(required)child-component
runManualbooleanfalseDon't run upload on handleFiles() - use runManual instead
keepOnFinishbooleanfalseKeep uploaded files in queue
fieldNamestring'file'Form-Field
method'POST' / 'PATCH' / 'PUT''POST'HTTP-Method
headersObject{}HTTP-Headers
interface FileUploaderChildrenProps {
    handleFiles: ((list: File[]) => void);
    queue: FileUpload[];
    runManual: () => void
}
interface FileUpload {
    progressTotal: number;
    progressLoaded: number;
    error: boolean;
    ready: boolean;
    upload: XHRUpload;  // don't access directly
    name: string;
}

FileDropzone

NameTypeDefaultDescription
onDrop *(files: File[]) => void(required)handler function
children *React.ReactNode;(required)
classNamestringundefined
classNameActivestringundefinedclass-name on dragActive
styleReact.CSSPropertiesundefined

FileSelect

NameTypeDefaultDescription
onChange: (files: File[]) => void(required)handler function
childrenReact.ReactNode(required)
multiplebooleanfalse
classNamestringundefined
styleReact.CSSPropertiesundefined

Keywords

FAQs

Package last updated on 03 Mar 2018

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