Skip to content

Latest commit

 

History

History
81 lines (62 loc) · 1.32 KB

File metadata and controls

81 lines (62 loc) · 1.32 KB

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-s3

Usage

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.