From fa6c815be6e2a5134a3a3d2d68d89e4e87f0ecb5 Mon Sep 17 00:00:00 2001 From: NameIsUser06 Date: Mon, 8 Jan 2024 09:47:23 +0900 Subject: [PATCH] fix : file null --- .../findfriend/domain/friend/service/PostFriendService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/investment/findfriend/domain/friend/service/PostFriendService.java b/src/main/java/com/investment/findfriend/domain/friend/service/PostFriendService.java index 34e51a9..3f46879 100644 --- a/src/main/java/com/investment/findfriend/domain/friend/service/PostFriendService.java +++ b/src/main/java/com/investment/findfriend/domain/friend/service/PostFriendService.java @@ -33,7 +33,10 @@ public ResponseEntity execute(PostFriendRequest request, MultipartFile f User user = userRepository.findByEmail(jwtUtil.extractEmail(httpServletRequest)) .orElseThrow(() -> UserNotFoundException.EXCEPTION); - File savedFile = file.isEmpty() ? fileRepository.save(File.builder().path(fileSaveUtil.save(file)).build()) : null; + File savedFile = null; + if (file != null && !file.isEmpty()) { + savedFile = fileRepository.save(File.builder().path(fileSaveUtil.save(file)).build()); + } Friend friend = Friend.builder() .user(user)