0.0.26 • Published 6 years ago

react-file-uploader1 v0.0.26

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
6 years ago

react-file-uploader

Simple React component to upload files with image cropper.

Installation

npm install --save react-file-uploader

or:

yarn add react-file-uploader

Usage

React-file-uploader is using React portals to display modal with file cropper. You need to create DOM node in the root of your project:

<div id="uploader-modal"></div>

Import ReactFileUploader component:

import ReactFileUploader from 'react-file-uploader';

function MyFileUploader() {
  return (
    <ReactFileUploader handleUploadFile={uploadFile} />
  );
}

Props

proptypedefaultdescription
acceptstringnull(optional) Types of files that uploader should accept
childrenrenderablenull(optional) Custom upload file input label
customLoaderrenderablenull(optional) Custom loader
handleUploadFilefunctionnull(required) Callback function uploading file to database
labelstringClick to upload file(optional) Custom label for default upload file button
styleobject{}(optional) Style object with 'uploadButtonStyle' key to override upload button in modal styles
uploadButtonLabelstringUpload file(optional) Custom label for upload button in modal

handleUploadFile example

const uploadFile = async(file, fileType) => {
  const formdata = new FormData();
  formdata.append('file', file);
  
  const options = {
    method: 'POST',
    formdata,
    headers: { Accept: 'application/json' },
    ...configToken,
  };
    
  try {
    await fetch(url, options);
  } catch(e) {
    showNotification(e);
  }
}

License

MIT

0.0.26

6 years ago

0.0.25

6 years ago

0.0.24

6 years ago

0.0.23

6 years ago

0.0.22

6 years ago

0.0.21

6 years ago

0.0.20

6 years ago

0.0.19

6 years ago

0.0.18

6 years ago

0.0.17

6 years ago

0.0.16

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago