I have 2 questions. I am using react-dropzone
How do I setup different settings? They have file.preview, max size and etc. How do I set this up in my react js? Is this on init or something?
I followed the example and now have OnDrop function but I am wondering how can I read the contents of a files(say a csv/text file) in my javascript code. The example just shows how to upload it to the server.
Right now I have
export default class TransactionHistory extends React.Component {
onDrop(acceptedFiles, rejectedFiles) {
acceptedFiles.forEach((file)=> {
console.log(file)
});
}
render() {
return (
<div>
<Dropzone onDrop={(acceptedFiles, rejectedFiles) => this.onDrop(acceptedFiles,rejectedFiles) }>
<div>Upload your transaction here. By Dragging and dropping your file here. Or double clicking here.</div>
</Dropzone>
</div>
)
}
}
Edit
Got the upload working
onDrop(acceptedFiles, rejectedFiles) {
acceptedFiles.forEach((file)=> {
var fr = new FileReader();
fr.onload = function(e) {
console.log(e.target.result);
};
fr.readAsText(file);
});
}
Now not sure how to set these "features"
disableClick [Boolean | **false**] — Clicking the <Dropzone> brings up the browser file picker.
multiple [Boolean | **true**] — Accept multiple files
minSize [Number | **0**] — Only accept file(s) larger than minSize bytes.
maxSize [Number | **Infinity**] — Only accept file(s) smaller than maxSize bytes.
accept - Accept only specified mime types. Must be a valid MIME type according to input element specification, for example application/pdf, image/*, audio/aiff,audio/midi