[ server ] [ oss ] -完成对象存储部分代码 - 2
This commit is contained in:
@@ -4,6 +4,7 @@ package io.wdd.func.oss.service;
|
|||||||
import com.amazonaws.SdkClientException;
|
import com.amazonaws.SdkClientException;
|
||||||
import com.amazonaws.services.s3.AmazonS3;
|
import com.amazonaws.services.s3.AmazonS3;
|
||||||
import com.amazonaws.services.s3.model.*;
|
import com.amazonaws.services.s3.model.*;
|
||||||
|
import io.wdd.common.handler.MyRuntimeException;
|
||||||
import io.wdd.func.oss.config.OssConfig;
|
import io.wdd.func.oss.config.OssConfig;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -104,10 +105,17 @@ public class OSSCoreServiceImpl implements OSSCoreService {
|
|||||||
|
|
||||||
AmazonS3 client = ossConfig.getClient();
|
AmazonS3 client = ossConfig.getClient();
|
||||||
|
|
||||||
return client.getObject(
|
try {
|
||||||
bucketName,
|
return client.getObject(
|
||||||
objectName
|
bucketName,
|
||||||
);
|
objectName
|
||||||
|
);
|
||||||
|
} catch (SdkClientException e) {
|
||||||
|
log.error("出查询单个对象 出现错误, 错误原因为 => {}", e.getMessage());
|
||||||
|
throw new MyRuntimeException(e.getMessage());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -146,9 +154,9 @@ public class OSSCoreServiceImpl implements OSSCoreService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("错误原因 => {}", e.getMessage());
|
log.error("查询对象的Head信息错误, 错误原因 => {}", e.getMessage());
|
||||||
|
|
||||||
return null;
|
throw new MyRuntimeException(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user