Error file if name does not match
Opened this issue · 0 comments
wsfuller commented
Trying to figure out how to error out a file if the naming is not expected.
constructor(props) {
super(props);
// For a full list of possible configurations,
// please consult http://www.dropzonejs.com/#configuration
this.djsConfig = {
addRemoveLinks: true,
acceptedFiles: "text/csv",
autoProcessQueue: false,
uploadMultiple: false,
maxFiles: 1
};
this.componentConfig = {
iconFiletypes: ['.csv'],
showFiletypeIcon: true,
postUrl: 'no-url',
};
this.errorFile = file => this.error(file); //>>>>>>>>>>>>>> Uncaught TypeError: _this.error is not a function
}
handleFileAdded(file) {
var fileName = file.name;
var expectedName = "name-of-file";
for (var i = 0; i < fileName.length; i++){
if (fileName[i] == '.'){
var newFileName = fileName.substring(0,i);
if (newFileName != expectedName){
this.errorFile(); // >>>>>>>>>>>>>>>>>>>>>>>>>>>>
alert('file is not the correct name');
} else {
console.log(file);
};
}
}
}
render() {
const config = this.componentConfig;
const djsConfig = this.djsConfig;
// For a list of all possible events (there are many), see README.md!
const eventHandlers = {
addedfile: this.handleFileAdded.bind(this),
error: this.errorFile
}
console.log(eventHandlers);
return <DropzoneComponent config={config} eventHandlers={eventHandlers} djsConfig={djsConfig} />
}
Is this something that can happen? Am I able to set what the name should be exactly and error out?