From 2db1aa88e8ab53096a936163d686b90d8e056a99 Mon Sep 17 00:00:00 2001
From: rain <167982779@qq.com>
Date: Wed, 21 Aug 2024 23:18:33 +0800
Subject: [PATCH] 国土对接返回信息加密

---
 src/main/java/com/dji/sample/component/oss/service/impl/MinIOServiceImpl.java |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/main/java/com/dji/sample/component/oss/service/impl/MinIOServiceImpl.java b/src/main/java/com/dji/sample/component/oss/service/impl/MinIOServiceImpl.java
index cafeb66..d54368e 100644
--- a/src/main/java/com/dji/sample/component/oss/service/impl/MinIOServiceImpl.java
+++ b/src/main/java/com/dji/sample/component/oss/service/impl/MinIOServiceImpl.java
@@ -1,5 +1,6 @@
 package com.dji.sample.component.oss.service.impl;
 
+import com.dji.sample.common.model.ResponseResult;
 import com.dji.sample.component.oss.model.OssConfiguration;
 import com.dji.sample.component.oss.model.enums.OssTypeEnum;
 import com.dji.sample.component.oss.service.IOssService;
@@ -29,7 +30,7 @@
 public class MinIOServiceImpl implements IOssService {
 
     private MinioClient client;
-    
+
     @Override
     public String getOssType() {
         return OssTypeEnum.MINIO.getType();
@@ -38,7 +39,7 @@
     @Override
     public CredentialsDTO getCredentials() {
         try {
-            AssumeRoleProvider provider = new AssumeRoleProvider(OssConfiguration.endpoint, OssConfiguration.accessKey,
+            AssumeRoleProvider provider = new AssumeRoleProvider(OssConfiguration.externalEndpoint, OssConfiguration.accessKey,
                     OssConfiguration.secretKey, Math.toIntExact(OssConfiguration.expire),
                     null, OssConfiguration.region, null, null, null, null);
             return new CredentialsDTO(provider.fetch(), OssConfiguration.expire);
@@ -63,7 +64,7 @@
         } catch (ErrorResponseException | InsufficientDataException | InternalException |
                 InvalidKeyException | InvalidResponseException | IOException |
                 NoSuchAlgorithmException | XmlParserException | ServerException e) {
-            throw new RuntimeException("The file does not exist on the OssConfiguration.");
+            throw new RuntimeException("OssConfiguration上不存在该文件.");
         }
     }
 
@@ -91,12 +92,12 @@
     }
 
     @Override
-    public void putObject(String bucket, String objectKey, InputStream input) {
+    public String putObject(String bucket, String objectKey, InputStream input) {
         try {
             client.statObject(StatObjectArgs.builder().bucket(bucket).object(objectKey).build());
-            throw new RuntimeException("The filename already exists.");
+            return "航线名重复";
         } catch (MinioException | InvalidKeyException | IOException | NoSuchAlgorithmException e) {
-            log.info("The file does not exist, start uploading.");
+            log.info("文件不存在,开始上传。");
             try {
                 ObjectWriteResponse response = client.putObject(
                         PutObjectArgs.builder().bucket(bucket).object(objectKey).stream(input, input.available(), 0).build());
@@ -106,6 +107,7 @@
                 ex.printStackTrace();
             }
         }
+        return null;
     }
 
     public void createClient() {

--
Gitblit v1.9.3