I use the reaction of creating a simple web page that loads multiple images using the dropzone-react component and sending it to the server using a reducer-dispatcher (REDUX).
Stuck on how to transfer my blobs files or an array of files queued in dropzone to a reducer.
Enter the codes for reference:
Change component class
class ImageUploadClass extends Component {
constructor(props){
super(props);
this.djsConfig = {
addRemoveLinks: true,
acceptedFiles: "image/jpeg,image/png,image/gif,application/pdf",
autoProcessQueue: false
};
this.componentConfig = {
iconFiletypes: ['.jpg', '.png', '.gif','.pdf'],
showFiletypeIcon: true,
postUrl: 'no-url'
};
this.dropzone = null;
}
handleFileAdded(file) {
console.log(file);
}
handlePost() {
console.log('Final Array'+this.dropzone.getQueuedFiles());
}
render() {
const {handleSubmit, pristine, reset, submitting} = this.props;
const config = this.componentConfig;
const djsConfig = this.djsConfig;
const eventHandlers = {
init: dz => this.dropzone = dz,
addedfile: this.handleFileAdded.bind(this)
}
return (
<form onSubmit={handleSubmit(imagesSubmit)}>
<div style={{'cursor':'pointer'}}>
<DropzoneComponent config={config} eventHandlers={eventHandlers} djsConfig={djsConfig} />
</div>
<button className="next action-button" ref={submit => this.submit = submit} type="submit" disabled={submitting} onClick={this.handlePost.bind(this)}>Submit</button>
</form>
);
}
}
ImageUploadClass = reduxForm({
form: 'ImageUploadClass'
})(ImageUploadClass);
export default ImageUploadClass;
Note. Constant function defined for form submission
const imagesSubmit = (values,dispatch) =>{
this.dropzone.getQueuedFiles();
return dispatch(submitFunctionToDispatcher(values));
}
The request is delivered to the dispatcher, but image files are not retrieved. Is it necessary to define a component for the same as defined for other reduction fields?
OR If anyone can suggest me upload files directly to S3?
Any help would be appreciated!