MultipartFile的属性(getOriginalFilename(),getName(),getResource(),getBytes(),getSize())

上传文件是116.jpg

@PostMapping("/test")  
public R uploadFile1(MultipartFile file) throws IOException {
    System.out.println("file.getOriginalFilename() = " + file.getOriginalFilename());  //116.jpg
    System.out.println("file.getName() = " + file.getName());  //file
    System.out.println("file.getContentType() = " + file.getContentType());  //image/jpeg
    System.out.println("file.getResource() = " + file.getResource());  //MultipartFile resource [file]
    System.out.println("file.getBytes() = " + file.getBytes());  //[B@4a75acdd
    System.out.println("file.getSize() = " + file.getSize());  //10059
    return R.ok();
}

结果:

posted @ 2022-08-16 10:46  xiexie0812  阅读(1204)  评论(0编辑  收藏  举报