Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
@Getter
@AllArgsConstructor
public enum S3ErrorCode implements BaseErrorCode {
UPLOAD_FAIL(HttpStatus.BAD_REQUEST, "S3_404", "μ—…λ‘œλ“œ μ‹€νŒ¨ν•˜μ˜€μŠ΅λ‹ˆλ‹€.");
UPLOAD_FAIL(HttpStatus.BAD_REQUEST, "S3_404", "μ—…λ‘œλ“œ μ‹€νŒ¨ν•˜μ˜€μŠ΅λ‹ˆλ‹€."),
_S3_NOT_FOUND(HttpStatus.NOT_FOUND,"S3400","파일이 μ‘΄μž¬ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€")
;



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.amazonaws.services.s3.model.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.example.backend.global.S3.exception.S3ErrorCode;
import org.example.backend.global.S3.exception.S3Exception;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
Expand Down Expand Up @@ -53,6 +55,9 @@ public void deleteFile(String key) {
* Presigned URL λ°œκΈ‰ (λ‹€μš΄λ‘œλ“œμš©)
*/
public String getPresignedUrl(String key) {
if(!amazonS3Client.doesObjectExist(bucket, key)) {
throw new S3Exception(S3ErrorCode._S3_NOT_FOUND);
}
Date expiration = new Date(System.currentTimeMillis() + 1000 * 60 * 60); // 1μ‹œκ°„

GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, key)
Expand Down