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
},
);