0.0.2 • Published 7 years ago
react-relay-upload-s3 v0.0.2
React Relay Upload S3
Middleware for Relay Modern Network Layer for upload file to AWS S3
Installation
Install react-relay-upload-s3 using yarn or npm:
yarn add react-relay-upload-s3Usage
How to create the RelayNetworkLayer
import {uploadS3Middleware} from 'react-relay-upload-s3';const network = new RelayNetworkLayer(
  [
    urlMiddleware(...),
    uploadS3Middleware({credentials: complexObjectsCredentials}),
    authMiddleware(...),
  ],
  {}
);How to use in commitMutation
    //single file
    const file:any = {
      bucket: bucket,
      key: key,
      region: region,
      file: selectedFile
    };
    commitMutation(
        ...
        uploadables: {
          file
        },
    );
    //multiple files
    const file1:any = {
      bucket: bucket,
      key: key1,
      region: region,
      file: selectedFile1
    };
    const file2:any = {
      bucket: bucket,
      key: key2,
      region: region,
      file: selectedFile2
    };
    commitMutation(
        ...
        uploadables: {
          file1,
          file2
        },
    );TODO
Document how to use urlMiddleware and authMiddleware in the context of AWS
License
React Relay Upload S3 is MIT licensed.