I'm using ReactJS frontend with SpringBoot and I get the above error. The root cause for this error is the MultiPartFile in DTO that I'm using to get data from the post request to the backend.
@Getter
@Setter
public class ItemDTO {
private long craftId;
private MultipartFile imgFile;
private int itemQuantity;
private String shortDescription;
private String longDescription;
}
The nested exception:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of
org.springframework.web.multipart.MultipartFile
(no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
code from the Reactjs frontend with: import {Button, Form, FormGroup, Label, Input,FormText} from 'reactstrap';
<FormGroup>
<Label for="exampleFile">File</Label>
<Input type="file" name="file" onChange={this.fileChangedHandler} id="exampleFile" />
</FormGroup>
fileChangedHandler = (event) => {
this.setState({ image: event.target.files[0] })
}
the console.log of the payload:
image: File
name: "1605baeba66180d5337f41d9c80617a9.jpg"
lastModified: 1578835072895
lastModifiedDate: Sun Jan 12 2020 18:47:52 GMT+0530 (India Standard Time) {}
webkitRelativePath: ""
size: 45002
type: "image/jpeg"
__proto__: File
Any help would be appreciated.