• Stars
    star
    102
  • Rank 335,584 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 9 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

React component of Input file and progress bar

React-fileupload-progress Build Status npm version

Gyazo

React component of Input file and progress bar. This component watch xhr uploading process, and trigger some events.

Installation

npm install --save react-fileupload-progress

API

FileUploadProgress

Props

  • url: File upload endpoint url. React.PropTypes.string.isRequired
  • method: Http request method. React.PropTypes.string.isRequired
Events

These handler will called on XMLHttpRequest's progress events. See also Using XMLHttpRequest on MDN.

  • onProgress: Called when xhr was loaded. Third parameter is the progress of uploading process(0 ~ 100). React.PropTypes.func(e, request, progress)

  • onLoad: Called when xhr was loaded. React.PropTypes.func(e, request)

  • onError: Called when xhr become error. React.PropTypes.func(e, request)

  • onAbort: Called when xhr was aborted. React.PropTypes.func(e, request)

Customization

It is possible to customize view and form.

  • formRenderer: For custom form rendering, Typo is fixed(#4) from v0.2.0 onSubmitHandler should be attach on your custom form's submit event. When onSubmitHandler is called, this component start observe xhr. React.PropTypes.func(onSubmitHandler)

  • formGetter: If custom formRenderer is used, you need to implement this method and must return FormData object. React.PropTypes.func => {return form}

  • progressRenderer: For custom progress rendering, First parameter is the progress of uploading process(0 ~ 100). If xhr has error, second parameter will be true. When third parameter is called, current xhr will be aborted. React.PropTypes.func(progress, hasError, cancelHandler)

  • formCustomizer: Called before xhr send. You can add any custom form parameter(e.g: id, name, etc) with this method. Must return form given as argument. React.PropTypes.func(form) => {return form}

  • beforeSend: Called before xhr send. You can customize xhr(e.g: HTTPHeader, etc) with this method. Must return request given as argument. React.PropTypes.func(request) => {return request}

Gyazo

Usage example

'use strict';

import React from 'react';
import FileUploadProgress  from 'react-fileupload-progress';


class App extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
      <div>
        <h3>Default style</h3>
        <FileUploadProgress key='ex1' url='http://localhost:3000/api/upload'
          onProgress={(e, request, progress) => {console.log('progress', e, request, progress);}}
          onLoad={ (e, request) => {console.log('load', e, request);}}
          onError={ (e, request) => {console.log('error', e, request);}}
          onAbort={ (e, request) => {console.log('abort', e, request);}}
          />
      </div>
    )
  }
};

React.render(<App/>, document.getElementById('out'));

See also example

npm install # or yarn
npm run start:example

Build

npm run build

Tests

npm test

More Repositories

1

markdown-edit

online markdown editor/viewer
HTML
206
star
2

react-draggable-tab

Atom like draggable tab react component
JavaScript
144
star
3

slidepad

HTML Slide Generator.
CoffeeScript
27
star
4

ws-tether

websocket-based tethering
JavaScript
8
star
5

react-mousetrap-mixin

React component and mixin for mousetrap
JavaScript
7
star
6

react-magic-effects

Magical effects for react components
JavaScript
6
star
7

m101j

Homework files of M101J MongoDB for Java Developers
Python
4
star
8

ACSEmailOutputBinding

Azure Communication Service Email output binding for Azure Function
C#
2
star
9

react-dropfile-field

Textarea react component with drop file preview
JavaScript
2
star
10

Hello-World

Hello World!
1
star
11

client_boilerplate

Client-side javascript project Boilerplate.
CoffeeScript
1
star
12

ts_boilerplate

JavaScript
1
star
13

webBoard

Realtime online whiteboard app using webSocket. Working on Node-jitsu
JavaScript
1
star
14

connect-ltsv-logger

ltsv format logger for (connect|express)
JavaScript
1
star
15

m102

Homework files of M102 MongoDB for DBAs
JavaScript
1
star
16

georgeosddev.github.com

souce of my Github Pages (http://georgeosddev.github.com)
CoffeeScript
1
star
17

patternMatchify.js

Pattern matching like Scala in JavaScript
JavaScript
1
star
18

backbone-slide.js

A very simple HTML presentation tool using backbone.js
JavaScript
1
star
19

CoffeeScriptServerSample

CoffeeScriptの勉強
CoffeeScript
1
star
20

railsinstaller_demo

Rails Installer Demo
Ruby
1
star
21

xitrum-polymer-sample

Xitrum component demo with Polymer
Scala
1
star
22

jekytrum

Simple static site generator
Scala
1
star
23

booklog

BookLog like Pinterest's interface
CoffeeScript
1
star
24

george-osd-site.docpad

source of http://george-osd-site.cloudfoundry.com/
CoffeeScript
1
star
25

coderwall-badged-icon-generator

Create coderwall-badged-icon
JavaScript
1
star
26

xitrum-leochat

Chat demo of xitrum with LeoFS
Java
1
star
27

voiceShortcut

JavaScript
1
star
28

longo

Asynchronous local database with a flavor of FRP.
JavaScript
1
star
29

syncStopWatch

JavaScript
1
star
30

resume

TypeScript
1
star
31

fluxflex-syncStopWatch

JavaScript
1
star
32

dotfiles

dotfiles
Shell
1
star
33

jwt-decoder

local jwt decoder
JavaScript
1
star
34

SimpleLogger

CoffeeScriptのLogger
CoffeeScript
1
star