1 | package org.cardanofoundation.explorer.api.service.impl; | |
2 | ||
3 | import java.io.IOException; | |
4 | ||
5 | import lombok.RequiredArgsConstructor; | |
6 | import lombok.extern.log4j.Log4j2; | |
7 | ||
8 | import org.springframework.beans.factory.annotation.Value; | |
9 | import org.springframework.stereotype.Service; | |
10 | ||
11 | import com.amazonaws.services.s3.AmazonS3; | |
12 | import com.amazonaws.services.s3.model.S3Object; | |
13 | import com.amazonaws.services.s3.model.S3ObjectInputStream; | |
14 | ||
15 | import org.cardanofoundation.explorer.api.service.StorageService; | |
16 | import org.cardanofoundation.explorer.common.exception.BusinessException; | |
17 | import org.cardanofoundation.explorer.common.exception.CommonErrorCode; | |
18 | ||
19 | @Service | |
20 | @RequiredArgsConstructor | |
21 | @Log4j2 | |
22 | public class StorageServiceImpl implements StorageService { | |
23 | ||
24 | private final AmazonS3 s3Client; | |
25 | ||
26 | @Value("${cloud.aws.s3.bucket.name}") | |
27 | private String bucketName; | |
28 | ||
29 | @Override | |
30 | public byte[] downloadFile(String fileName) { | |
31 | S3Object s3Object = s3Client.getObject(bucketName, fileName); | |
32 | S3ObjectInputStream inputStream = s3Object.getObjectContent(); | |
33 | try { | |
34 |
1
1. downloadFile : replaced return value with null for org/cardanofoundation/explorer/api/service/impl/StorageServiceImpl::downloadFile → NO_COVERAGE |
return inputStream.readAllBytes(); |
35 | } catch (IOException e) { | |
36 |
1
1. downloadFile : removed call to java/io/IOException::printStackTrace → NO_COVERAGE |
e.printStackTrace(); |
37 | throw new BusinessException(CommonErrorCode.UNKNOWN_ERROR); | |
38 | } | |
39 | } | |
40 | } | |
Mutations | ||
34 |
1.1 |
|
36 |
1.1 |