useS3FileUpload
The useS3FileUpload hook accepts an options object that allows customization of the file upload behavior. Available options include:
-
multiple(boolean, optional): Allow multiple file uploads at once. Default isfalse. -
maxFiles(number, optional): Set the maximum number of files that can be uploaded. -
maxFileSize(number, optional): Specify the maximum allowed file size for uploads.
useS3FileUpload returns an object with the following properties:
-
uploadedFiles(array): An array of objects containing information about the uploaded files. Each object has the following properties:name(string): The name of the file.size(number): The size of the file in bytes.type(string): The MIME type of the file.url(string): The URL of the uploaded file.delete(function): A function that deletes the file from S3.
-
uploadFiles(function): A function that triggers the file upload process. This function accepts an array of files as an argument. -
reset(function): A function that resets theuploadedFilesarray.
const { uploadedFiles, uploadFiles, reset } = useS3FileUpload({
multiple: true, // Allow multiple flie uploads (optional)
maxFiles: 10, // 10 files limit (optional)
maxFileSize: 10 * 1024 * 1024, // 10MB limit (optional)
});