添加exist
This commit is contained in:
parent
c8874064f0
commit
a46d4d8fac
@ -211,6 +211,14 @@ final public class AliOssAdapter extends AStorageAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isExists(String ...path) {
|
||||||
|
try (OSSWrapper wrapper = getOssClient()) {
|
||||||
|
OSS ossClient = wrapper.getOSSClient();
|
||||||
|
return ossClient.doesObjectExist(config.getBucketName(), buildPath(path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private OSSWrapper getOssClient() {
|
private OSSWrapper getOssClient() {
|
||||||
OSS ossClient = new OSSClientBuilder().build(config.getEndpoint(), config.getAccessKeyId(), config.getAccessKeySecret());
|
OSS ossClient = new OSSClientBuilder().build(config.getEndpoint(), config.getAccessKeyId(), config.getAccessKeySecret());
|
||||||
return new OSSWrapper(ossClient);
|
return new OSSWrapper(ossClient);
|
||||||
|
@ -206,6 +206,16 @@ public class AwsOssAdapter extends AStorageAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isExists(String... path) {
|
||||||
|
try (S3Wrapper wrapper = getS3Client()) {
|
||||||
|
AmazonS3Client s3Client = wrapper.getS3Client();
|
||||||
|
return s3Client.doesObjectExist(config.getBucketName(), buildPath(path));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private S3Wrapper getS3Client() {
|
private S3Wrapper getS3Client() {
|
||||||
BasicAWSCredentials basicAwsCred = new BasicAWSCredentials(config.getAccessKeyId(), config.getAccessKeySecret());
|
BasicAWSCredentials basicAwsCred = new BasicAWSCredentials(config.getAccessKeyId(), config.getAccessKeySecret());
|
||||||
ClientConfiguration clientConfiguration = new ClientConfiguration();
|
ClientConfiguration clientConfiguration = new ClientConfiguration();
|
||||||
|
@ -26,4 +26,6 @@ public interface IStorageAdapter {
|
|||||||
List<StorageFileObject> listDir(String ...path);
|
List<StorageFileObject> listDir(String ...path);
|
||||||
boolean deleteDir(String ...path);
|
boolean deleteDir(String ...path);
|
||||||
boolean setAcl(StorageAcl acl, String ...path);
|
boolean setAcl(StorageAcl acl, String ...path);
|
||||||
|
|
||||||
|
boolean isExists(String ...path);
|
||||||
}
|
}
|
||||||
|
@ -60,4 +60,9 @@ public class LocalStorageAdapter extends AStorageAdapter{
|
|||||||
public boolean setAcl(StorageAcl acl, String... path) {
|
public boolean setAcl(StorageAcl acl, String... path) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isExists(String... path) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user