An open API service indexing awesome lists of open source software.

https://github.com/wh5938316/use-s3-uploader

Aws S3 signed url uploader & hooks for React
https://github.com/wh5938316/use-s3-uploader

aws aws-s3 hooks react s3 signed-urls typescript uploader

Last synced: 12 months ago
JSON representation

Aws S3 signed url uploader & hooks for React

Awesome Lists containing this project

README

          

use-s3-uploader
===========================

From Browser
------------

```jsx
import React, { useRef } from 'react';
import { useS3Uploader } from 'use-s3-uploader';

const Example = (props) => {
const inputRef = useRef(null);

const getSignedUrl = (file, next) => {
next({
signedUrl: "https://example.amazonaws.com/test.jpg?x-amz-acl=......."
});
};

const onUploadStart = (file, next) => {
next(file);
}

const onProgress = (percent, status, file) => {
console.log('onProgress', percent, status, file)
}

const onError = (error, file) => {
console.log(error, file)
}

const onFinish = (signResult, file) => {
console.log(signResult, file);
}

useS3Uploader({
getSignedUrl: getSignedUrl,
onUploadStart: onUploadStart,
onProgress: onProgress,
onError: onError,
onFinish: onFinish,
accept: 'image/*',
uploadRequestHeaders: {
'x-amz-acl': 'public-read',
},
contentDisposition: 'auto',
}, inputRef);

return (




)
}

export default Example;
```