|
@@ -71,16 +71,53 @@ public class OssUtils {
|
|
|
return new ByteArrayInputStream(bytes);
|
|
return new ByteArrayInputStream(bytes);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public VaultsResponse<String> uploadArrayFile2(MultipartFile dto) {
|
|
|
|
|
+ // 创建OSSClient实例。
|
|
|
|
|
+ OSS ossClient = new OSSClientBuilder().build(endPoint, accessKeyId, secretAccessKey);
|
|
|
|
|
+ try {
|
|
|
|
|
+ //设置文件名
|
|
|
|
|
+ Integer pos = dto.getOriginalFilename().lastIndexOf('.');
|
|
|
|
|
+ String suffix = "";
|
|
|
|
|
+ if (pos != -1) {
|
|
|
|
|
+ suffix = dto.getOriginalFilename().substring(pos);
|
|
|
|
|
+ }
|
|
|
|
|
+ String fileName = dir+"S"+123+"N-"+ CgpTool.generateUUID() +suffix;
|
|
|
|
|
+ // 创建PutObject请求。
|
|
|
|
|
+ ossClient.putObject(bucketName, fileName, dto.getInputStream());
|
|
|
|
|
+
|
|
|
|
|
+ String url = "https://" + bucketName + "." + endPoint + "/" + fileName;
|
|
|
|
|
+ // System.out.println(url);
|
|
|
|
|
+ return VaultsResponse.success(url);
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ return null;
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ if (ossClient != null) {
|
|
|
|
|
+ ossClient.shutdown();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
public VaultsResponse<List<PriceUploadDto>> uploadArrayFile(List<PriceUploadDto> dto) {
|
|
public VaultsResponse<List<PriceUploadDto>> uploadArrayFile(List<PriceUploadDto> dto) {
|
|
|
Long orderId = null;
|
|
Long orderId = null;
|
|
|
|
|
+ Boolean checked = false;
|
|
|
for (PriceUploadDto uploadDto : dto) {
|
|
for (PriceUploadDto uploadDto : dto) {
|
|
|
if(uploadDto.getOrderId() != null){
|
|
if(uploadDto.getOrderId() != null){
|
|
|
orderId = uploadDto.getOrderId();
|
|
orderId = uploadDto.getOrderId();
|
|
|
}
|
|
}
|
|
|
|
|
+ if(StringUtils.isNotEmpty(uploadDto.getBase64())){
|
|
|
|
|
+ checked = true;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
if(orderId == null){
|
|
if(orderId == null){
|
|
|
return VaultsResponse.failed("关键参数为空");
|
|
return VaultsResponse.failed("关键参数为空");
|
|
|
}
|
|
}
|
|
|
|
|
+ if(!checked){
|
|
|
|
|
+ return VaultsResponse.success();
|
|
|
|
|
+ }
|
|
|
// 创建OSSClient实例。
|
|
// 创建OSSClient实例。
|
|
|
OSS ossClient = new OSSClientBuilder().build(endPoint, accessKeyId, secretAccessKey);
|
|
OSS ossClient = new OSSClientBuilder().build(endPoint, accessKeyId, secretAccessKey);
|
|
|
try {
|
|
try {
|