mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-20 18:15:56 +08:00
feature 升级aws-s3到2.X版本
This commit is contained in:
parent
0d3d9d359b
commit
7338d7cdc8
@ -29,16 +29,6 @@
|
||||
<dependency>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>s3</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>netty-nio-client</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>software.amazon.awssdk</groupId>
|
||||
<artifactId>apache-client</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@ -74,6 +74,9 @@ public class OssClient {
|
||||
|
||||
createBucket();
|
||||
} catch (Exception e) {
|
||||
if (e instanceof OssException) {
|
||||
throw e;
|
||||
}
|
||||
throw new OssException("配置错误! 请检查系统配置:[" + e.getMessage() + "]");
|
||||
}
|
||||
}
|
||||
@ -168,6 +171,21 @@ public class OssClient {
|
||||
return upload(file, getPath(properties.getPrefix(), suffix));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件元数据
|
||||
*
|
||||
* @param path 完整文件路径
|
||||
*/
|
||||
public HeadObjectResponse getObjectMetadata(String path) {
|
||||
path = path.replace(getUrl() + "/", "");
|
||||
HeadObjectRequest headObjectRequest = HeadObjectRequest.builder()
|
||||
.bucket(properties.getBucketName())
|
||||
.key(path)
|
||||
.build();
|
||||
|
||||
return client.headObject(headObjectRequest);
|
||||
}
|
||||
|
||||
public InputStream getObjectContent(String path) {
|
||||
path = path.replace(getUrl() + "/", "");
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user