0.1.0 • Published 6 years ago

react-drag-n-drop-to-s3 v0.1.0

Weekly downloads
8
License
MIT
Repository
github
Last release
6 years ago

react-drag-n-drop-to-s3

React component to drag and drop files and upload them to AWS S3. Based on react-dropzone and react-s3-uploader.

Install

$ npm install react-drag-n-drop-to-s3 react-dropzone

Example

import DragNDropToS3 from 'react-drag-n-drop-to-s3'

const UploadAvatar = () => (
  <DragNDropToS3
    dropzoneProps={{
      accept: 'image/png',
      maxSize: 2000000,
    }}
    s3UploaderProps={{
      getSignedUrl: APIs.getSignedURL,
      autoUpload: true,
      onFinish: response => console.log(response.publicUrl),
    }}
  >
    {({ acceptedFiles }) => (
      <div>
        <p>Drop your avatar here or click to upload</p>
        <ul>
          {acceptedFiles.map((file, i) => (
            <li key={i}>{file.name}</li>
          ))}
        </ul>
      </div>
    )}
  </DragNDropToS3>
)

Props

PropDescriptionTypeRequired
dropzonePropsFor the list of available options, see react-dropzoneObjectNo
s3UploaderPropsFor the list of available options, see react-s3-uploaderObjectNo