mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-05-08 03:37:28 +08:00
feat: add internalServerError
This commit is contained in:
@@ -28,8 +28,13 @@ public class UserController {
|
|||||||
|
|
||||||
@PostMapping("/me/avatar")
|
@PostMapping("/me/avatar")
|
||||||
public ResponseEntity<?> uploadAvatar(@RequestParam("file") MultipartFile file,
|
public ResponseEntity<?> uploadAvatar(@RequestParam("file") MultipartFile file,
|
||||||
Authentication auth) throws IOException {
|
Authentication auth) {
|
||||||
String url = imageUploader.upload(file.getBytes(), file.getOriginalFilename()).join();
|
String url = null;
|
||||||
|
try {
|
||||||
|
url = imageUploader.upload(file.getBytes(), file.getOriginalFilename()).join();
|
||||||
|
} catch (IOException e) {
|
||||||
|
return ResponseEntity.internalServerError().body(Map.of("url", url));
|
||||||
|
}
|
||||||
userService.updateAvatar(auth.getName(), url);
|
userService.updateAvatar(auth.getName(), url);
|
||||||
return ResponseEntity.ok(Map.of("url", url));
|
return ResponseEntity.ok(Map.of("url", url));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user