|
|
@@ -1,30 +1,16 @@
|
|
|
package com.jzg.quotation.summary.factory.decorator.image;
|
|
|
|
|
|
-import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.jzg.commons.entity.vo.ImagesVo;
|
|
|
import com.jzg.commons.entity.vo.InsTaskImagesVo;
|
|
|
-import com.jzg.commons.exception.SystemException;
|
|
|
-import com.jzg.commons.util.MinioUtils;
|
|
|
import com.jzg.quotation.commons.entity.vo.aggregated.InsuranceUploadImageVo;
|
|
|
-import com.jzg.quotation.commons.entity.vo.aggregated.QuoteResultsVo;
|
|
|
-import com.jzg.quotation.commons.entity.vo.aggregated.QuoteVo;
|
|
|
-import com.jzg.quotation.commons.entity.vo.aggregated.UploadImageVo;
|
|
|
import com.jzg.quotation.commons.entity.vo.image.InsuranceImageVo;
|
|
|
import com.jzg.quotation.commons.service.QuotationApiBaseService;
|
|
|
-import com.jzg.quotation.summary.entity.vo.QuoteNumRedisVo;
|
|
|
import com.jzg.quotation.summary.service.InsTaskImagesService;
|
|
|
-import com.jzg.quotation.summary.service.SysQuoteConfigService;
|
|
|
-import com.jzg.quotation.summary.service.SysQuoteRedisService;
|
|
|
import io.minio.GetObjectArgs;
|
|
|
import io.minio.MinioClient;
|
|
|
-import io.minio.errors.*;
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
-import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.security.InvalidKeyException;
|
|
|
-import java.security.NoSuchAlgorithmException;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -74,8 +60,9 @@ public class ImageParamHandlerDecorator {
|
|
|
InsuranceImageVo.ImageDTO imageDTO = new InsuranceImageVo.ImageDTO();
|
|
|
imageDTO.setImageId(imageVo.getImageId());
|
|
|
imageDTO.setImageName(imageVo.getFileName());
|
|
|
- String fileBase64 = getFileBase64(minioClient, bucketName, imageVo.getFileName());
|
|
|
- imageDTO.setImageBase64Str(fileBase64);
|
|
|
+ byte[] fileToByte = getFileToByte(minioClient, bucketName, imageVo.getFileName());
|
|
|
+ imageDTO.setImageBase64Str(Base64.getEncoder().encodeToString(fileToByte));
|
|
|
+ imageDTO.setImageByte(fileToByte);
|
|
|
return imageDTO;
|
|
|
}).collect(Collectors.toList());
|
|
|
vo.setImageBase64List(imageDTOList);
|
|
|
@@ -120,4 +107,28 @@ public class ImageParamHandlerDecorator {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取文件bytes数组
|
|
|
+ * @param minioClient
|
|
|
+ * @param bucketName
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public byte[] getFileToByte(MinioClient minioClient,String bucketName,String imageName){
|
|
|
+ try (InputStream stream = minioClient.getObject(
|
|
|
+ GetObjectArgs.builder().bucket(bucketName).object(imageName).build());
|
|
|
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
|
|
|
+ // 读取流数据
|
|
|
+ byte[] buffer = new byte[4096];
|
|
|
+ int bytesRead;
|
|
|
+ while ((bytesRead = stream.read(buffer)) != -1) {
|
|
|
+ outputStream.write(buffer, 0, bytesRead);
|
|
|
+ }
|
|
|
+ return outputStream.toByteArray();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|