File tree Expand file tree Collapse file tree
src/main/java/com/example/solidconnection/s3 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import com .example .solidconnection .s3 .dto .UploadedFileUrlResponse ;
66import com .example .solidconnection .s3 .dto .urlPrefixResponse ;
77import com .example .solidconnection .s3 .service .S3Service ;
8- import com .example .solidconnection .siteuser .domain .SiteUser ;
98import lombok .RequiredArgsConstructor ;
109import org .springframework .beans .factory .annotation .Value ;
1110import org .springframework .http .ResponseEntity ;
@@ -45,11 +44,11 @@ public ResponseEntity<UploadedFileUrlResponse> uploadPreProfileImage(
4544
4645 @ PostMapping ("/profile/post" )
4746 public ResponseEntity <UploadedFileUrlResponse > uploadPostProfileImage (
48- @ AuthorizedUser SiteUser siteUser ,
47+ @ AuthorizedUser long siteUserId ,
4948 @ RequestParam ("file" ) MultipartFile imageFile
5049 ) {
5150 UploadedFileUrlResponse profileImageUrl = s3Service .uploadFile (imageFile , ImgType .PROFILE );
52- s3Service .deleteExProfile (siteUser );
51+ s3Service .deleteExProfile (siteUserId );
5352 return ResponseEntity .ok (profileImageUrl );
5453 }
5554
Original file line number Diff line number Diff line change 55import static com .example .solidconnection .common .exception .ErrorCode .NOT_ALLOWED_FILE_EXTENSIONS ;
66import static com .example .solidconnection .common .exception .ErrorCode .S3_CLIENT_EXCEPTION ;
77import static com .example .solidconnection .common .exception .ErrorCode .S3_SERVICE_EXCEPTION ;
8+ import static com .example .solidconnection .common .exception .ErrorCode .USER_NOT_FOUND ;
89
910import com .amazonaws .AmazonServiceException ;
1011import com .amazonaws .SdkClientException ;
@@ -109,7 +110,9 @@ private String getFileExtension(String fileName) {
109110 * - 기존 파일의 key(S3파일명)를 찾는다.
110111 * - S3에서 파일을 삭제한다.
111112 * */
112- public void deleteExProfile (SiteUser siteUser ) {
113+ public void deleteExProfile (long siteUserId ) {
114+ SiteUser siteUser = siteUserRepository .findById (siteUserId )
115+ .orElseThrow (() -> new CustomException (USER_NOT_FOUND ));
113116 String key = siteUser .getProfileImageUrl ();
114117 deleteFile (key );
115118 }
You can’t perform that action at this time.
0 commit comments