调整客户端获取方式
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user