Skip to content

Commit

Permalink
[feat] log ์ฐ๊ธฐ
Browse files Browse the repository at this point in the history
  • Loading branch information
khee2 committed Jun 11, 2024
1 parent 49e74a5 commit a24722e
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,18 @@ public S3Service(AmazonS3 amazonS3) {
this.amazonS3 = amazonS3;
}

public String upload(String dirName, String fileName, MultipartFile multipartFile) throws IOException { // dirName์˜ ๋””๋ ‰ํ† ๋ฆฌ๊ฐ€ S3 Bucket ๋‚ด๋ถ€์— ์ƒ์„ฑ๋จ
File uploadFile = convert(multipartFile)
.orElseThrow(() -> new IllegalArgumentException("MultipartFile -> File ์ „ํ™˜ ์‹คํŒจ"));
return upload(dirName, fileName, uploadFile);
public String upload(String dirName, String fileName, MultipartFile multipartFile) throws IOException {
try {
File uploadFile = convert(multipartFile)
.orElseThrow(() -> new IllegalArgumentException("MultipartFile -> File ์ „ํ™˜ ์‹คํŒจ: ํŒŒ์ผ ๋ณ€ํ™˜ ์ค‘ ์˜ˆ์™ธ ๋ฐœ์ƒ"));
return upload(dirName, fileName, uploadFile);
} catch (RuntimeException e) {
log.error("์•Œ ์ˆ˜ ์—†๋Š” ์˜ˆ์™ธ ๋ฐœ์ƒ: ํŒŒ์ผ ์—…๋กœ๋“œ ์‹คํŒจ. ๋””๋ ‰ํ† ๋ฆฌ ์ด๋ฆ„: {}, ํŒŒ์ผ ์ด๋ฆ„: {}, ์›๋ณธ ํŒŒ์ผ ์ด๋ฆ„: {}, ์—๋Ÿฌ ๋ฉ”์‹œ์ง€: {}",
dirName, fileName, multipartFile.getOriginalFilename(), e.getMessage(), e);
throw new RuntimeException("ํŒŒ์ผ ์—…๋กœ๋“œ ์ค‘ ์•Œ ์ˆ˜ ์—†๋Š” ์˜ˆ์™ธ ๋ฐœ์ƒ. ๋””๋ ‰ํ† ๋ฆฌ ์ด๋ฆ„: " + dirName +
", ํŒŒ์ผ ์ด๋ฆ„: " + fileName + ", ์›๋ณธ ํŒŒ์ผ ์ด๋ฆ„: " + multipartFile.getOriginalFilename() +
", ์—๋Ÿฌ ๋ฉ”์‹œ์ง€: " + e.getMessage(), e);
}
}

private String upload(String dirName, String fileName, File uploadFile) {
Expand Down

0 comments on commit a24722e

Please sign in to comment.