Skip to content

Commit

Permalink
Replace PreSigned URL in HTTPS (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
inh2613 authored Nov 8, 2023
2 parents cdd6bdb + 9ca67dc commit fc1e9f6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,12 @@ public boolean isExist(String id) {
* @return: 기프트 카드가 존재하는지 여부
*/
public boolean isExist(Long voucherId) {
return giftCardRepository.existsByVoucherId(voucherId);
if (giftCardRepository.existsByVoucherId(voucherId)) {
if (giftCardRepository.findAllByVoucherId(voucherId).get().getExpiresAt().isAfter(LocalDateTime.now())) {
return true;
}
}
return false;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ public String getPresignedUrl(String dirName, String filename) {
GeneratePresignedUrlRequest generatePresignedUrlRequest =
new GeneratePresignedUrlRequest(bucketName, key, HttpMethod.GET)
.withExpiration(new Date(System.currentTimeMillis() + 1000 * 60 * 5));
return amazonS3Client.generatePresignedUrl(generatePresignedUrlRequest).toString();
return amazonS3Client.generatePresignedUrl(generatePresignedUrlRequest).toString().replace("https://", "http://");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public VoucherReadResponseDto mapToDto(Voucher voucher) {
.expiresAt(voucher.getExpiresAt().toString())
.imageUrl(voucher.getImageUrl())
.accessible(voucher.getDeletedAt() == null)
.shared(giftCardService.read(voucher.getId()).isEnable())
.shared(giftCardService.isExist(voucher.getId()))
.build();
return voucherReadResponseDto;
}
Expand Down

0 comments on commit fc1e9f6

Please sign in to comment.