简体   繁体   中英

how to catch a file on the rest api controller and what method to send it with Postman

I do not know how to catch the file on the rest api controller and what method to send it to Postman, please help me will be very grateful)

Body

邮差的身体

Headers

邮差标题

Controller

调节器

To post a file through postman you need a method something like :

@PostMapping(path = "/post", consumes = { "multipart/form-data" })
public ResponseEntity<String> uploadFile(@RequestParam(name = "file") MultipartFile file, @RequestParam("message")String message, @RequestParam("subject")Integer subject ){
//You can then get any info about file like : 
System.out.println(file.getName()); 
System.out.println(file.getOriginalName()); 
System.out.println(file.getContentType()); 
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM