Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: S3 convert 오류 해결 #86

Closed
wants to merge 17 commits into from
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
fca7dfe
feat: 9번째 문제를 막으면 우승자를 찾아 1명이면 우승자를 기록한다
gikhoon Feb 18, 2024
61297b7
feat: 킹문제 member들과 우승자 저장 로직 구현중
gikhoon Feb 18, 2024
d0a534f
refactor: 해야 할일 주석 추가
gikhoon Feb 19, 2024
38289e4
feat: 킹킹문제 푸는 사람 임시 저장
gikhoon Feb 19, 2024
e5a8776
Merge remote-tracking branch 'origin/develop' into feature/record#4
gikhoon Feb 19, 2024
8875688
feat: Education class에 우승자 column 제거
gikhoon Feb 19, 2024
1822072
feat: 킹킹문제 멤버, 우승자 저장 로직 구현
gikhoon Feb 19, 2024
5f9f035
refactor: 10번 문제 풀이 코드 리펙토링
gikhoon Feb 19, 2024
085e236
refactor: 코드 리펙토링
gikhoon Feb 19, 2024
2748f0a
fix: 세션 생성 시 0주차부터 생성
Youthhing Feb 19, 2024
6f31b69
refactor: 쓰지 않는 패키지 제거 및 DTO 생성 메서드 명 변경
Youthhing Feb 19, 2024
767df05
refactor: 결승 진출 멤버 관련 서비스 분리
Youthhing Feb 19, 2024
c541811
feat: 킹킹 문제 반환 API에서 아직 킹킹멤버가 없으면 NOT_FOUND EXCEPTION 발생하게 구현
gikhoon Feb 20, 2024
eea99ce
refactor: 교육에 해당하는 결승 진출 조회 로직 API 엔드포인트 변경
Youthhing Feb 20, 2024
c8a4770
feat: 교육 우승자 조회 컨트롤러 구현
Youthhing Feb 20, 2024
c300ebd
fix: S3 convert 문제 해결을 위해 파일 명에 randomUUID 값 추가
gikhoon Feb 20, 2024
3e7b715
Merge remote-tracking branch 'origin/develop' into feature/record#4-2
gikhoon Feb 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/main/java/cotato/csquiz/global/S3/S3Uploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.amazonaws.services.s3.model.PutObjectRequest;
import cotato.csquiz.exception.ErrorCode;
import cotato.csquiz.exception.ImageException;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -30,11 +31,11 @@ public String uploadFiles(MultipartFile multipartFile, String dirName) throws Im
log.info("upload Files {}",multipartFile);
File uploadFile = convert(multipartFile)
.orElseThrow(() -> new ImageException(ErrorCode.IMAGE_PROCESSING_FAIL));
return upload(uploadFile, dirName);
return upload(uploadFile, dirName, multipartFile.getOriginalFilename());
}

private String upload(File uploadFile, String dirName) {
String fileName = dirName + "/" + uploadFile.getName();
private String upload(File uploadFile, String dirName, String originalName) {
String fileName = dirName + "/" + UUID.randomUUID() + originalName;
String uploadUrl = putS3(uploadFile, fileName);
removeNewFile(uploadFile);
log.info(uploadUrl);
Expand All @@ -55,8 +56,8 @@ private String putS3(File uploadFile, String fileName) {
}

private Optional<File> convert(MultipartFile file) throws ImageException {
File convertFile = new File(System.getProperty("user.dir") + "/" + file.getOriginalFilename());
log.info("original file name: {}",file.getOriginalFilename());
File convertFile = new File(System.getProperty("user.dir") + "/" + UUID.randomUUID());
log.info("original file name: {}",convertFile.getName());

try {
log.info("convert try start");
Expand All @@ -68,7 +69,7 @@ private Optional<File> convert(MultipartFile file) throws ImageException {
return Optional.of(convertFile);
}
} catch (IOException e) {
log.info("convert 실패");
log.info("convert 실패", e);
throw new ImageException(ErrorCode.IMAGE_PROCESSING_FAIL);
}
log.info("convert empty");
Expand Down
Loading