Created
August 24, 2018 22:54
-
-
Save mstrYoda/daeef287b0648a1b13ebf9ba324cbfa6 to your computer and use it in GitHub Desktop.
Java MultipartFile Controller for medium article
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
@RequestMapping("/users") | |
public class UserController { | |
UserService userService; | |
@Autowired | |
public UserController(UserService userService) { | |
this.userService = userService; | |
} | |
@PostMapping({"/", ""}) | |
public String post(@RequestPart("request") UserCreateRequest request, @RequestPart("file") MultipartFile file) { | |
// some application logic here | |
userService.create(request); | |
return file.getOriginalFilename().replaceAll(" ", "").trim(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment