From d21fb3ce5dc70314995ffd3ad4b86b263bba11c3 Mon Sep 17 00:00:00 2001 From: yunhacandy Date: Wed, 11 Sep 2024 00:31:13 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=A4=91=EB=B3=B5=EC=9D=84=20=EB=B0=A9=EC=A7=80=ED=95=98?= =?UTF-8?q?=EA=B8=B0=20=EC=9C=84=ED=95=B4=20uuid=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/cotato/growingpain/s3/S3Uploader.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/cotato/growingpain/s3/S3Uploader.java b/src/main/java/cotato/growingpain/s3/S3Uploader.java index 05579a2..b1843fb 100644 --- a/src/main/java/cotato/growingpain/s3/S3Uploader.java +++ b/src/main/java/cotato/growingpain/s3/S3Uploader.java @@ -9,6 +9,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.Optional; +import java.util.UUID; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -62,7 +63,7 @@ private void removeNewFile(File targetFile) { } private Optional convert(MultipartFile file) throws IOException { - File convertFile = new File(System.getProperty("user.dir") + "/" + file.getOriginalFilename()); + File convertFile = new File(System.getProperty("user.dir") + "/" + UUID.randomUUID() + file.getOriginalFilename()); try { if (convertFile.createNewFile()) { // 바로 위에서 지정한 경로에 File이 생성됨 (경로가 잘못되었다면 생성 불가능) FileOutputStream fos = new FileOutputStream(convertFile); // FileOutputStream 데이터를 파일에 바이트 스트림으로 저장하기 위함