1.0.2 • Published 7 years ago

react-grid-uploader v1.0.2

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

react-grid-uploader

The grid uploader for Amazon S3 in ReactJS. Please see features in below:

  1. Upload multiple files at same times by drag-n-drop (using react-dropzone)
  2. Upload directly to S3 with signed url (using react-s3-uploader
  3. Rotate/Delete.
  4. View gallery in lightbox with react-image-lightbox

Sample

Installation

npm i --save react-grid-uploader
or
yarn add react-grid-uploader

Please file an issue if you have any trouble!

Usage

import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import GridUploader from 'react-grid-uploader';

class App extends Component {

  onGetData = () => {
    console.log(this.gridContainer.getData());
    alert('check console to see the data structure');
  }

  render() {
    return (
      <div className="App">
        <div className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h2>Welcome to Grid Uploader</h2>
          <button onClick={this.onGetData}>Get Data</button>
        </div>
        <div>
          <GridUploader ref={(ref) => { this.gridContainer = ref; }}
            signingUrl="http://localhost:8000/s3/sign" />
        </div>
      </div>
    );
  }
}

export default App;

Props

NameTypeInfo
signingUrlStringYour backend service that uses to generate signed url from AWS_ACCESS_KEY_ID & AWS_SECRET_ACCESS_KEY. See at for example service https://github.com/odysseyscience/react-s3-uploader
onUploadFinishFunctionthe callback function when upload completely.
onUploadErrorFunctionthe callback function when upload failed.
onUploadProgressFunctionthe callback function when upload in progress.
onItemSelectFunctionthe callback function when select an image item.
onItemDeleteFunctionthe callback function when delete an image item.
customStyleFunctionthe custom style for grid uploader.

customStyle Object

Property NameTypeInfo
containerStyleObjectstyle for grid container. Default is width: '100%', backgroundColor: '#333333', minHeight: '600px'
nameStyleObjectstyle of image name.
descriptionStyleObjectstyle of image description.
imageBorderColorStringborder color of image in normal state.
imageBorderActiveColorStringborder color of image in active state.
iconContainerStyleObjectstyle of icon container
iconStyleObjectstyle of icon
progressColorStringcolor of cirle progress. Default is #fbba00

Response data structure

To get grid data, we call getData() and receive array of image data. Each item has the structure as below:

Property NameTypeInfo
s3DataObjectThe uploaded response from AWS S3.
descriptionStringDescription of image.
rotateIntegerRotage degree of image.
OthersProperties from react-dropzone.

License

MIT