Morrys Repositories

Morrys Repositories

  • Docs
  • GitHub

›React Relay Upload S3

React Relay AppSync

  • Getting Started

React Relay Auth IAM

  • React Relay Auth IAM

React Relay Upload S3

  • React Relay Upload S3

React Relay Upload S3

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-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
        },
    );
Last updated on 2019-5-5 by morrys
← React Relay Auth IAM
  • Installation
  • Usage
Morrys Repositories
Docs
about relay-hooks
Community
User Showcase
More
GitHubStar
Follow @m0rrys
Facebook Open Source
Copyright © 2019 Lorenzo Di Giacomo