[8/7] 5주차 회의 #102
2020147542
started this conversation in
General
Replies: 3 comments 2 replies
-
1. 지난주에 한 일 |
Beta Was this translation helpful? Give feedback.
1 reply
-
3. 다음회의 날짜다음주 화요일(8월 13일) 8시 |
Beta Was this translation helpful? Give feedback.
1 reply
-
*** 참고 사항 ***
// TODO: s3에 이미지 업로드
private String uploadFile(MultipartFile file) throws IOException {
if (file.getOriginalFilename() == null || file.getOriginalFilename().isEmpty()) {
throw new MemberHandler(ErrorStatus._BAD_REQUEST);
}
String fileName = newFileName(file.getOriginalFilename()); // s3에 저장될 이름
File convertedFile = convertMultiPartToFile(file); // 임시파일로 변경한 후 업로드
try {
amazonS3Client.putObject(new PutObjectRequest(bucket, fileName, convertedFile));
return amazonS3Client.getUrl(bucket, fileName).toString();
} finally {
convertedFile.delete(); // 임시 파일 삭제
}
}
// TODO: multipartFile -> 임시 File로 변경
private File convertMultiPartToFile(MultipartFile file) throws IOException {
File convertedFile = new File(Objects.requireNonNull(file.getOriginalFilename()));
try (FileOutputStream fos = new FileOutputStream(convertedFile)) {
fos.write(file.getBytes());
}
return convertedFile;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
-
이번주에 한 일과 다음주까지 해야할 일을 말해봅시다.
Beta Was this translation helpful? Give feedback.
All reactions