-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BE] feat : AWS S3 파일 삭제 기능 수정 및 리팩토링
- Loading branch information
Showing
12 changed files
with
66 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
@Builder | ||
public record FileAddRequest( | ||
String uploadFilePath | ||
String uploadFilePath, | ||
String studentId | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
|
||
public record FileDeleteRequest( | ||
String uploadFilePath, | ||
String uuidFileName | ||
String fileName | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
backend/src/main/java/booki_today/implement/file/FileDeleter.java
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
backend/src/main/java/booki_today/implement/file/FileRemover.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package booki_today.implement.file; | ||
|
||
import booki_today.dto.file.FileDeleteRequest; | ||
import booki_today.global.annotation.Implement; | ||
import booki_today.global.error.InternalServerException; | ||
import com.amazonaws.SdkClientException; | ||
import com.amazonaws.services.s3.AmazonS3; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Value; | ||
|
||
import static booki_today.global.constant.FileExceptionConstant.FILE_DELETE_ERROR; | ||
|
||
@Implement | ||
@Slf4j | ||
public class FileRemover { | ||
|
||
private final AmazonS3 amazonS3; | ||
@Value("${cloud.aws.s3.bucket}") | ||
private String bucketName; | ||
|
||
public FileRemover(final AmazonS3 amazonS3) { | ||
this.amazonS3 = amazonS3; | ||
} | ||
|
||
public void deleteFile(final FileDeleteRequest fileDeleteRequest){ | ||
try{ | ||
String uploadFilePath = fileDeleteRequest.uploadFilePath(); | ||
String fileName = fileDeleteRequest.fileName(); | ||
String key = uploadFilePath+"/"+fileName; | ||
|
||
amazonS3.deleteObject(bucketName, key); | ||
}catch (SdkClientException e){ | ||
log.error("Exception [Err_Location]: {}", e.getStackTrace()[0]); | ||
throw new InternalServerException(FILE_DELETE_ERROR.message()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters