diff --git a/src/main/java/hsu/umc/server/aws/s3/AmazonS3Manager.java b/src/main/java/hsu/umc/server/aws/s3/AmazonS3Manager.java index 9e31fb7..2093619 100644 --- a/src/main/java/hsu/umc/server/aws/s3/AmazonS3Manager.java +++ b/src/main/java/hsu/umc/server/aws/s3/AmazonS3Manager.java @@ -27,7 +27,8 @@ public String uploadFile(String keyName, MultipartFile file)throws IOException { return amazonS3.getUrl(amazonConfig.getBucket(),keyName).toString(); } public void deleteFile(String photoUrl){ - amazonS3.deleteObject(new DeleteObjectRequest(amazonConfig.getBucket(),photoUrl)); + String s3Key = photoUrl.replace("https://umc-7th.s3.ap-northeast-2.amazonaws.com/", ""); + amazonS3.deleteObject(new DeleteObjectRequest(amazonConfig.getBucket(), s3Key)); } public String generatePhotoKeyName(Uuid uuid) { return amazonConfig.getPhotoPath() + '/' + uuid.getUuid() + ".png"; diff --git a/src/main/java/hsu/umc/server/service/SchedulerServiceImpl.java b/src/main/java/hsu/umc/server/service/SchedulerServiceImpl.java index b9174d4..2e56883 100644 --- a/src/main/java/hsu/umc/server/service/SchedulerServiceImpl.java +++ b/src/main/java/hsu/umc/server/service/SchedulerServiceImpl.java @@ -26,7 +26,7 @@ public class SchedulerServiceImpl implements SchedulerService{ public void deletePhoto() { List photoList = photoRepository.findAll(); photoList.stream() - .filter(photo -> Duration.between(photo.getCreatedAt(), LocalDateTime.now()).toHours()>=2) + .filter(photo -> Duration.between(photo.getCreatedAt(), LocalDateTime.now()).toMinutes() >= 1) .forEach(photo -> { s3Manager.deleteFile(photo.getPhotoUrl()); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index af4d031..e7b2ada 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -31,7 +31,7 @@ cloud: static: ap-northeast-2 stack: auto: false - cron: "0 0 */1 * * *" + cron: "0 * * * * *" credentials: accessKey: ${aws.access.key.id} secretKey: ${aws.secret.access.key} diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 3dc43f3..434ee3b 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -32,7 +32,7 @@ cloud: static: ap-northeast-2 stack: auto: false - cron: "0 */2 * * * *" + cron: "0 * * * * *" credentials: accessKey: ${aws.access.key.id} secretKey: ${aws.secret.access.key} \ No newline at end of file