//测试 使用 swagger 进行文件上传
@ApiOperation(value = "上传图片", notes = "上传图片", httpMethod="POST" ,consumes="multipart/form-data")
@ApiImplicitParams({
@ApiImplicitParam(name = "file", paramType="form", value = "临时文件", dataType="file", required = true),
})
@PostMapping(value = "/uploadFile")
@ResponseBody
public String uploadFile(
@ApiParam(value="文件",required=true)
MultipartFile file) throws IOException {
JSONObject jsonObject = new JSONObject(true);
jsonObject.put("fileName",file.getName());
jsonObject.put("contentType",file.getContentType());
jsonObject.put("originalFileName",file.getOriginalFilename());
jsonObject.put("size",file.getSize());
jsonObject.put("stream",file.getInputStream());
jsonObject.put("byte[]",file.getBytes());
return jsonObject.toString();
}
swagger 和 spring boot 实现文件上传
最新推荐文章于 2024-05-17 10:34:17 发布