Yuvaleros / material-ui-dropzone

A Material-UI file upload dropzone
MIT License
483 stars 248 forks source link

Does material-ui-dropzone support custom error messages #349

Open Tulean opened 2 years ago

Tulean commented 2 years ago

Bug Report

Describe the bug

Does material-ui-dropzone support custom error messages?

Steps to reproduce

I need to validate whether a file/files were uploaded. Does this package support error handling in terms of some props that we could input to?

Maqil commented 2 years ago

@Tulean You can use these 4 methods to handle each case you can use it like this:

  <DropzoneArea
     acceptedFiles={acceptedFileFormat}
     onChange={handleFileChange}
     onDrop={handleFileDrop}
     filesLimit={1}
     maxFileSize={6000000}
     showFileNames
     getFileAddedMessage={(fileName) => `${fileName} ADDED!`}
     getDropRejectMessage={(rejectedFile) => `${rejectedFile} REJECTED!`}
     getFileRemovedMessage={(fileName) => `${fileName} REMOVED!`}
     getFileLimitExceedMessage={(filesLimit) => `:filesLimit ${filesLimit}`}
   />