diff --git a/plugin.xml b/plugin.xml
index 96cd029..ea9f893 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -5,12 +5,13 @@
com.fanruan.fs
yes
no
- 1.1.2
+ 1.1.3
10.0
2020-01-27
richie
[2020-06-30]修复定时调度无法使用的问题。
[2020-06-15]支持区域设置。
[2020-06-12]初始化插件。
diff --git a/src/main/java/com/fanruan/fs/s3/repository/core/S3Config.java b/src/main/java/com/fanruan/fs/s3/repository/core/S3Config.java
index 2512321..87beb64 100644
--- a/src/main/java/com/fanruan/fs/s3/repository/core/S3Config.java
+++ b/src/main/java/com/fanruan/fs/s3/repository/core/S3Config.java
@@ -4,6 +4,7 @@ import com.fr.config.Identifier;
import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
import com.fr.io.config.CommonRepoConfig;
+import com.fr.io.context.ResourceModuleContext;
import com.fr.io.context.info.GetConfig;
import com.fr.io.context.info.SetConfig;
import com.fr.stable.StringUtils;
@@ -84,6 +85,19 @@ public class S3Config extends CommonRepoConfig {
this.bucket.set(bucket);
}
+ @Override
+ public void update(String key) {
+ super.update(key);
+ S3Config newConfig = ResourceModuleContext.getRepoConfig(S3RepositoryFactory.IDENTITY, key);
+ if (newConfig != null) {
+ this.setEndPoint(newConfig.getEndPoint());
+ this.setRegion(newConfig.getRegion());
+ this.setAccessKeyId(newConfig.getAccessKeyId());
+ this.setAccessKeySecret(newConfig.getAccessKeySecret());
+ this.setBucket(newConfig.getBucket());
+ }
+ }
+
@Override
public S3Config clone() throws CloneNotSupportedException {
S3Config cloned = (S3Config) super.clone();
diff --git a/src/main/java/com/fanruan/fs/s3/repository/core/S3RepositoryProfile.java b/src/main/java/com/fanruan/fs/s3/repository/core/S3RepositoryProfile.java
index 6331dfb..372a8f2 100644
--- a/src/main/java/com/fanruan/fs/s3/repository/core/S3RepositoryProfile.java
+++ b/src/main/java/com/fanruan/fs/s3/repository/core/S3RepositoryProfile.java
@@ -30,6 +30,8 @@ public class S3RepositoryProfile extends RepositoryProfile {
this.s3Config.set(s3Config);
}
+
+
@Override
public RepositoryProfile clone() throws CloneNotSupportedException {
S3RepositoryProfile cloned = (S3RepositoryProfile) super.clone();
diff --git a/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java b/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java
index f3ced78..99b549a 100644
--- a/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java
+++ b/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java
@@ -5,6 +5,8 @@ import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.client.builder.AwsClientBuilder;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
+import com.amazonaws.services.s3.model.CopyObjectRequest;
+import com.amazonaws.services.s3.model.DeleteObjectRequest;
import com.amazonaws.services.s3.model.GetObjectRequest;
import com.amazonaws.services.s3.model.ListObjectsRequest;
import com.amazonaws.services.s3.model.ObjectListing;
@@ -71,7 +73,9 @@ public class S3ResourceRepository extends BaseResourceRepository {
ObjectListing objectListing = s3.listObjects(listObjectsRequest);
for (S3ObjectSummary summary : objectListing.getObjectSummaries()) {
String key = summary.getKey();
- result.add(s3Object2FileEntry(summary, key));
+ if (!key.endsWith(DELIMITER)) {
+ result.add(s3Object2FileEntry(summary, key));
+ }
}
for (String prefix : objectListing.getCommonPrefixes()) {
FineFileEntry entry = new FineFileEntry(prefix);
@@ -224,6 +228,20 @@ public class S3ResourceRepository extends BaseResourceRepository {
return s3Object.getObjectMetadata().getContentLength();
}
+ @Override
+ public boolean rename(String path, String newPath) throws ResourceIOException {
+ try {
+ CopyObjectRequest copyObjRequest = new CopyObjectRequest(bucket,
+ path, bucket, newPath);
+ s3.copyObject(copyObjRequest);
+ s3.deleteObject(new DeleteObjectRequest(bucket, path));
+ } catch (Exception e) {
+ LogKit.error(e.getMessage(), e);
+ return false;
+ }
+ return true;
+ }
+
@Override
public void shutDown() {
s3.shutdown();
@@ -233,4 +251,5 @@ public class S3ResourceRepository extends BaseResourceRepository {
public String getIdentity() {
return S3RepositoryFactory.IDENTITY;
}
+
}