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 (
<div>
<input type='file' ref={inputRef} multiple={true} />
</div>
)
}
export default Example;
-
Notifications
You must be signed in to change notification settings - Fork 1
wh5938316/use-s3-uploader
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Aws S3 signed url uploader & hooks for React
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published