Skip to content

Commit

Permalink
Move formData to state (note: not working)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattchrlw committed May 1, 2021
1 parent 3c4ff90 commit 09247da
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions elpis/gui/src/components/Dataset/FileUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {connect} from "react-redux";
class FileUpload extends Component {
constructor(props) {
super(props);
this.state = {missingFiles: []};
this.state = {missingFiles: [], formData: new FormData()};
}

parseElan = async (file) => {
Expand Down Expand Up @@ -54,17 +54,20 @@ class FileUpload extends Component {

if (!wavFileNames.includes(parsedWavFile) && !wavFileNames.includes(identicalWavFile)) {
this.setState(prevState => ({
...prevState,
missingFiles: [...prevState.missingFiles, [identicalWavFile, parsedWavFile]],
}));
}
}

var formData = new FormData();

acceptedFiles.forEach(file => {
formData.append("file", file);
this.setState(prevState => ({
...prevState,
formData: {...prevState.formData, ["file"]: file}
}));
});
this.props.datasetFiles(formData);

this.props.datasetFiles(this.state.formData);
}

render() {
Expand Down

0 comments on commit 09247da

Please sign in to comment.