Skip to content

Instantly share code, notes, and snippets.

@mstrYoda
Created August 24, 2018 22:54
Show Gist options
  • Save mstrYoda/daeef287b0648a1b13ebf9ba324cbfa6 to your computer and use it in GitHub Desktop.
Save mstrYoda/daeef287b0648a1b13ebf9ba324cbfa6 to your computer and use it in GitHub Desktop.
Java MultipartFile Controller for medium article
@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