# react-fine-uploader **Repository Path**: mirrors_fkhadra/react-fine-uploader ## Basic Information - **Project Name**: react-fine-uploader - **Description**: Easily integrate Fine Uploader or Fine Uploader S3 into a React app. Drop-in high-level components for a turn-key UI. Use small focused components to build a more custom UI. - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-08 - **Last Updated**: 2026-02-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README [![npm](https://img.shields.io/npm/v/react-fine-uploader.svg)](https://www.npmjs.com/package/react-fine-uploader) [![license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE) [![Build Status](https://travis-ci.org/FineUploader/react-fine-uploader.svg?branch=master)](https://travis-ci.org/FineUploader/react-fine-uploader) [![Sauce Test Status](https://saucelabs.com/browser-matrix/react-fine-uploader2.svg)](https://saucelabs.com/u/react-fine-uploader2) Makes using [Fine Uploader](http://fineuploader.com) in a React app simple. Drop-in high-level components for a turn-key UI. Use small focused components to build a more custom UI. **This is currently an unstable in-progress project. Breaking changes may occur at any time without notice until the version has reached 1.0.** Please see the ["first stable release" project](https://github.com/FineUploader/react-fine-uploader/projects/1) for 1.0 goals. ## Docs ### Overview React Fine Uploader makes using Fine Uploader and all of its unique features very simple in a React-based project. Thie library provides useful resources that can be divided into three sections: #### Individual focused components (like `` and ``). These allow you to easily build a highly customizable and powerful UI for your upload widget, backed by Fine Uploader's core feature set. Most of these components are unstyled (i.e. ready to be styled by you). Focused component-specific stylesheets may be provided at a later date. #### Higher-order components (like ``) These combine many focused components that provide style (which can be adjusted via your own stylesheet) and enhanced UI-specific features. These components are essentially "turn-key", which means that you can get a fully functional upload widget up and running in your project with a few lines of code. Keep in mind that you of course still need a server to handle the requests sent by Fine Uploader and to server up the JavaScript and CSS files. #### Wrapper classes These wrap a Fine Uploader instance for use in React Fine Uploader. They provide additional features such as the ability to dynamically register multiple event/callback listeners. All individual and higher-order/focused components require you to pass a constructed wrapper class instance. More information, such as examples and API documentation, can be found in the README of the [fine-uploader-wrappers project](https://github.com/FineUploader/fine-uploader-wrappers). ### Quick Reference - [Installing](#installing) - [High-level Components](#high-level-components) - [``](#gallery-) - [Low-level Components](#low-level-components) - [``](#cancelbutton-) - [``](#deletebutton-) - [``](#dropzone-) - [``](#fileinput-) - [``](#filename-) - [``](#filesize-) - [``](#pauseresumebutton-) - [``](#progressbar-) - [``](#retrybutton-) - [``](#status-) - [``](#thumbnail-) ### Installing 0.1.0 is the first version of react-fine-uploader published on npm. Two dependencies that you will need to install yourself: an A+/Promise spec compliant polyfill (for IE11) and React (which is a peer dependency). Simply `npm install react-fine-uploader` and see the documentation for your specific integration instructions (based on your needs). ### High-level Components #### `` Similar to the Fine Uploader UI gallery template, the `` component lays out an uploader using all of the available [low-level components](#low-level-components). Appealing styles are provided, which can be easily overriden in your own style sheet. In the `` component, each file is rendered as a "card". CSS transitions are used to fade a card in when a file is submitted and then fade it out again when the file is either canceled during uploading or deleted after uploading. By default, a file input element is rendered and styled to allow access to the file chooser. And, if supported by the device, a drop zone is rendered as well. ##### Properties The only required property is `uploader`, which must be a Fine Uploader [wrapper class](#wrapper-classes) instance. But you can pass any property supported by any low-level component through `` by following this simple convention: `{lowerCamelCaseComponentName}-{propertyName}: {value}`. For example, if you want to specify custom child elements for the [`` element](#fileinput-), you would initialize the component like so: ```js const fileInputChildren = Choose files render() { return ( ) } ``` And if you wanted to instead change the rendered text for the [`` element](#status-) when the file uploads successfully, you would initialize your component like this: ```js const statusTextOverride = { upload_successful: 'Success!' } render() { return ( ) } ``` Note that you can also disable some components by passing a `disabled` property. Currently, this is limited to the `` component and the `` component. For example, if you wanted to prevent file dropping, your code would look similar to this: ```js render() { return ( ) } ``` Finally, you may disable the add/remove file animations by setting the `animationsDisabled` property to `true`. ##### A simple example For example, if you render a `` component using the following code: ```js import React, { Component } from 'react' import FineUploaderTraditional from 'fine-uploader-wrappers' import Gallery from 'react-fine-uploader' // ...or load this specific CSS file using a tag in your document import 'react-fine-uploader/gallery/gallery.css' const uploader = new FineUploaderTraditional({ options: { chunking: { enabled: true }, deleteFile: { enabled: true, endpoint: '/uploads' }, request: { endpoint: '/uploads' }, retry: { enableAuto: true } } }) class UploadComponent extends Component { render() { return ( ) } } export default UploadComponent ``` ...you will see this initial UI on page load: After setting up a [server to handle the upload and delete requests](http://docs.fineuploader.com/branch/master/quickstart/03-setting_up_server.html), and dropping a few files, you will see a modern-looking upload user interface with your files represented like so: ### Low-level Components #### `` The `` component allows you to easily render a useable cancel button for a submitted file. An file can be "canceled" at any time, except after it has uploaded successfully, and before it has passed validation (and of course after it has already been canceled). By default, the `` will be rendered and clickable only when the associated file is eligible for cancelation. Otherwise, the component will _not_ render a button. In other words, once, for example, the associated file has been canceled or has uploaded successfully, the button will essentially disappear. You can change this behavior by setting appropriate options. ##### Properties - `children` - (child elements/components of ``. Use this for any text of graphics that you would like to display inside the rendered button. If the component is childless, the button will be rendered with a simple text node of "Cancel". - `id` - The Fine Uploader ID of the submitted file. (required) - `onlyRenderIfCancelable` - Defaults to `true`. If set to `false`, the element will be rendered as a disabled button if the associated file is not cancelable. - `uploader` - A Fine Uploader [wrapper class](#wrapper-classes). (required) The example below will include a cancel button for each submitted file along with a [``](#thumbnail-), and will ensure the elements representing a file are removed if the file is canceled. ```javascript import React, { Component } from 'react' import ReactDOM from 'react-dom' import CancelButton from 'react-fine-uploader/cancel-button' import FineUploaderTraditional from 'fine-uploader-wrappers' import Thumbnail from 'react-fine-uploader/thumbnail' const uploader = new FineUploader({ options: { request: { endpoint: 'my/upload/endpoint' } } }) export default class FileListener extends Component { constructor() { super() this.state = { submittedFiles: [] } } componentDidMount() { uploader.on('statusChange', (id, oldStatus, newStatus) => { if (newStatus === 'submitted') { const submittedFiles = this.state.submittedFiles submittedFiles.push(id) this.setState({ submittedFiles }) } else if (isFileGone(newStatus)) { const submittedFiles = this.state.submittedFiles const indexToRemove = submittedFiles.indexOf(id) submittedFiles.splice(indexToRemove, 1) this.setState({ submittedFiles }) } }) } render() { return (
{ this.state.submittedFiles.map(id => {
}) }
) } } const isFileGone = status => { return [ 'canceled', 'deleted', ].indexOf(status) >= 0 } ``` You may pass _any_ standard [`