use of com.github.lybgeek.file.dto.FileConvertResultDTO in project springboot-learning by lyb-geek.
the class FileController method upload.
@PostMapping(value = "/upload")
@ResponseBody
public Result<String> upload(@RequestParam("file") MultipartFile file) throws IOException {
Map<String, Object> params = new HashMap<>();
params.put(FileConstant.FILE_PARAM_KEY, file.getBytes());
String response = HttpClientUtil.INSTANCE.post(FileConstant.PREVIEW_REMOTE_URL, params, file.getOriginalFilename());
FileConvertResultDTO fileConvertResultDTO = JSON.parseObject(response, FileConvertResultDTO.class);
if (ObjectUtils.isNotEmpty(fileConvertResultDTO) && FileConstant.SUCCESS.equals(fileConvertResultDTO.getStatus())) {
return new Result<String>().setData(fileConvertResultDTO.getTargetFileName());
}
throw new BizException("文件上传解析预览失败", 406);
}
Aggregations