feat: add internalServerError

This commit is contained in:
Tim
2025-07-01 10:25:35 +08:00
parent 664d7de105
commit a37f046898

View File

@@ -28,8 +28,13 @@ public class UserController {
@PostMapping("/me/avatar")
public ResponseEntity<?> uploadAvatar(@RequestParam("file") MultipartFile file,
Authentication auth) throws IOException {
String url = imageUploader.upload(file.getBytes(), file.getOriginalFilename()).join();
Authentication auth) {
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);
return ResponseEntity.ok(Map.of("url", url));
}