Yuvaleros / material-ui-dropzone

A Material-UI file upload dropzone
MIT License
484 stars 247 forks source link

Question: Rejecting file programmatically with custom snackbar message #296

Open RobertJSmith opened 3 years ago

RobertJSmith commented 3 years ago

Hi,

I'm using DropzoneAreaBase and I'm trying to figure out if there's a way I can reject a file from the function I've provided as the onAdd prop. I have two state arrays. tempFiles which I use as the DropzoneAreaBase fileObject prop and mediaFiles which stores the files confirmed for upload. When the user clicks a button I transfer the contents of the tempFiles array into the mediaFiles array, empty the tempFile array and show a different component that gives the user the options of uploading those files or adding more files. I'd use the one array but I want to save on screen space and only allow 3 files to be added at a time. Ideally if the user tries to add a file that already exists in the mediaFiles array, I'd like to reject it and show a rejected snackbar message. Does anyone have any ideas on how I could do this?

filingroove commented 3 years ago

@RobertJSmith Hey :) Have you found a way to do this?

filingroove commented 3 years ago

React-dropzone has custom validation functions. I think there's no reason not to pass this prop to react-dropzone directly :)

Naveenbc commented 1 year ago

@filingroove , @RobertJSmith Were you able to solve this?