diff --git a/src/main/java/aws/teamthreefive/aws/s3/AmazonS3Manager.java b/src/main/java/aws/teamthreefive/aws/s3/AmazonS3Manager.java index 39bc026..9525497 100644 --- a/src/main/java/aws/teamthreefive/aws/s3/AmazonS3Manager.java +++ b/src/main/java/aws/teamthreefive/aws/s3/AmazonS3Manager.java @@ -21,11 +21,11 @@ public class AmazonS3Manager { private final AmazonS3 amazonS3; private final AmazonConfig amazonConfig; - public String uploadFile(String KeyName, MultipartFile file){ + public String uploadFileWithContentType(String KeyName, MultipartFile file){ System.out.println(KeyName); ObjectMetadata metadata = new ObjectMetadata(); - // metaData는 필수는 아니고 추가적인 정보를 담아주는 것입니다. + metadata.setContentType(file.getContentType()); metadata.setContentLength(file.getSize()); try { diff --git a/src/main/java/aws/teamthreefive/diecast/service/DiecastCommandService.java b/src/main/java/aws/teamthreefive/diecast/service/DiecastCommandService.java index ae9905c..66853ec 100644 --- a/src/main/java/aws/teamthreefive/diecast/service/DiecastCommandService.java +++ b/src/main/java/aws/teamthreefive/diecast/service/DiecastCommandService.java @@ -48,21 +48,13 @@ public Photo savePhoto(Long diecastUuid, DiecastRequestDTO.PhotoDTO request) { .build() ); - String photoUrl = s3Manager.uploadFile(s3Manager.generatePhotoKeyName(savedUuid), request.getPhotoFile()); + String photoUrl = s3Manager.uploadFileWithContentType(s3Manager.generatePhotoKeyName(savedUuid), request.getPhotoFile()); Photo photo = DiecastConverter.toPhoto(request, photoUrl); photo.setDiecast(diecastRepository.findById(diecastUuid).get()); -// photo = PhotoConverter.toPhoto(fileUrl); - - /// - //photo.setPhotoUrl(fileUrl); - /// - return photoRepository.save(photo); -// return photoRepository.save(PhotoConverter.toPhoto(photoUrl, photo)); -// return photoRepository.save(PhotoConverter.toPhoto(fileUrl)); } diff --git a/src/main/java/aws/teamthreefive/diecastvideo/dto/DiecastvideoRequestDTO.java b/src/main/java/aws/teamthreefive/diecastvideo/dto/DiecastvideoRequestDTO.java index c030f47..14447c5 100644 --- a/src/main/java/aws/teamthreefive/diecastvideo/dto/DiecastvideoRequestDTO.java +++ b/src/main/java/aws/teamthreefive/diecastvideo/dto/DiecastvideoRequestDTO.java @@ -13,9 +13,8 @@ public class DiecastvideoRequestDTO { @Setter public static class DiecastvideoDTO { @NotNull -// String diecastvideoUrl; MultipartFile diecastvideo; -// List diecastvideo; +// String videoType; } } diff --git a/src/main/java/aws/teamthreefive/diecastvideo/service/DiecastvideoCommandService.java b/src/main/java/aws/teamthreefive/diecastvideo/service/DiecastvideoCommandService.java index 8130dc1..5d6afa6 100644 --- a/src/main/java/aws/teamthreefive/diecastvideo/service/DiecastvideoCommandService.java +++ b/src/main/java/aws/teamthreefive/diecastvideo/service/DiecastvideoCommandService.java @@ -25,7 +25,6 @@ public class DiecastvideoCommandService { private final AmazonS3Manager s3Manager; public Diecastvideo saveDiecastvideo(DiecastvideoRequestDTO.DiecastvideoDTO request) { - //Diecastvideo diecastvideo = DiecastvideoConverter.toDiecastvideo(request); String uuid = UUID.randomUUID().toString(); Uuid savedUuid = uuidRepository.save( @@ -34,9 +33,10 @@ public Diecastvideo saveDiecastvideo(DiecastvideoRequestDTO.DiecastvideoDTO requ .build() ); - String diecastvideoUrl = s3Manager.uploadFile(s3Manager.generateVideoKeyName(savedUuid), request.getDiecastvideo()); + String diecastvideoUrl = s3Manager.uploadFileWithContentType(s3Manager.generateVideoKeyName(savedUuid), request.getDiecastvideo()); return diecastvideoRepository.save(DiecastvideoConverter.toDiecastvideo(diecastvideoUrl)); + }