Is it possible with spring boot and for example apache poi to get POST request json format with excel file inside? for example :
POST api/testrequest/
Content-Type: application/json //(maybe another type?)
{
"searchKey": "test1",
"searchValue": file.excel
}
And fetch it to Object?
Now I did something like this :
Controller method :
@PostMapping(
value = "excelentity",
consumes = {MediaType.MULTIPART_FORM_DATA_VALUE, MediaType.APPLICATION_JSON_VALUE})
public String getExcelAndParseItToEntity(@RequestBody ExcelTemplate file) {
String fileName = file.getFile().getOriginalFilename();
log.info(fileName);
return "test case";
}
And Java Object :
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class ExcelTemplate {
private MultipartFile file;
private String name;
}
But it doesn't work