调整客户端获取方式
This commit is contained in:
8
.idea/modules.xml
generated
8
.idea/modules.xml
generated
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/huawei-obs-springboot-starter.iml" filepath="$PROJECT_DIR$/huawei-obs-springboot-starter.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.njcn.huawei.obs.constant;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2023年09月23日 14:11
|
||||
*/
|
||||
public interface ExceptionConstant {
|
||||
|
||||
String UPLOAD_ERROR = "上传异常";
|
||||
|
||||
String BUCKET_ERROR ="bucket桶异常";
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.njcn.huawei.obs.util;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.huawei.obs.config.HuaweiObsProperties;
|
||||
import com.njcn.huawei.obs.constant.ExceptionConstant;
|
||||
import com.obs.services.ObsClient;
|
||||
import com.obs.services.exception.ObsException;
|
||||
import com.obs.services.model.*;
|
||||
@@ -10,12 +11,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
@@ -94,14 +92,12 @@ public class OBSUtil {
|
||||
// 读取该已上传对象的URL
|
||||
log.info("已上传对象的URL" + result.getObjectUrl());
|
||||
return result.getObjectUrl();
|
||||
} catch (ObsException e) {
|
||||
log.error("obs上传失败", e);
|
||||
} catch (IOException e) {
|
||||
} catch (ObsException | IOException e) {
|
||||
log.error("上传失败", e);
|
||||
throw new RuntimeException(ExceptionConstant.UPLOAD_ERROR);
|
||||
} finally {
|
||||
huaweiObsProperties.destroy(obsClient);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/***
|
||||
@@ -243,6 +239,7 @@ public class OBSUtil {
|
||||
log.info("Error Message: " + e.getErrorMessage());
|
||||
log.info("Request ID:" + e.getErrorRequestId());
|
||||
log.info("Host ID:" + e.getErrorHostId());
|
||||
throw new RuntimeException(ExceptionConstant.BUCKET_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#Generated by Maven
|
||||
#Wed Mar 08 15:30:34 CST 2023
|
||||
#Sat Sep 23 14:16:08 CST 2023
|
||||
version=1.0.0
|
||||
groupId=com.njcn
|
||||
artifactId=huawei-obs-springboot-starter
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
com\njcn\huawei\obs\config\HuaweiObsProperties.class
|
||||
com\njcn\Main.class
|
||||
com\njcn\huawei\obs\util\OBSUtil.class
|
||||
com\njcn\huawei\obs\constant\ExceptionConstant.class
|
||||
com\njcn\Main.class
|
||||
META-INF\spring-configuration-metadata.json
|
||||
com\njcn\huawei\obs\config\HuaweiObsProperties$Obs.class
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
E:\gitea\huawei-obs-springboot-starter\src\main\java\com\njcn\huawei\obs\util\OBSUtil.java
|
||||
E:\gitea\huawei-obs-springboot-starter\src\main\java\com\njcn\Main.java
|
||||
E:\gitea\huawei-obs-springboot-starter\src\main\java\com\njcn\huawei\obs\constant\ExceptionConstant.java
|
||||
E:\gitea\huawei-obs-springboot-starter\src\main\java\com\njcn\huawei\obs\config\HuaweiObsProperties.java
|
||||
|
||||
Reference in New Issue
Block a user