felixrieseberg / felixrieseberg/React-Dropzone-Component
Error file if name does not match
- Dominant language
- JavaScript
- Stars
- 999
- Forks
- 148
- PR merge metrics
- No merged PRs in 30d
Description
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
}
Is this something that can happen? Am I able to set what the name should be exactly and error out?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with README.md and the DropzoneComponent event-handler configuration shown in the issue. Confirm whether exact filename validation and an error callback are supported; done means documenting or implementing a clear way to reject a mismatched filename without the reported TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100