Compare commits

..

10 Commits

Author SHA1 Message Date
Seth.Tian 638f5cab3f Pull request #19: QFX-5192 回退,改为修改metadata的length 4 years ago
Seth.Tian 6ca4a6a943 Merge remote-tracking branch 'origin/master' 4 years ago
Seth.Tian 7317ba5d24 QFX-5192 update:写入的方法回退,改为修改metadata的length 4 years ago
Seth.Tian 5793a02da6 Pull request #18: QFX-5192 update:更新版本号,修复一个key存在但是length不一样时会导致写入文件不对的问题 4 years ago
Seth.Tian 42110ac049 QFX-5192 update:更新版本号,修复一个key存在但是length不一样时会导致写入失败的问题 4 years ago
richie ff1ca0bc3c 应该在父依赖下申明 4 years ago
ju|剧浩宇 07283b3bf3 Pull request #13: 无jira任务 更新依赖以及版本号 4 years ago
Seth.Tian b471687529 无jira任务 update:更新依赖以及版本号 4 years ago
Echen 5a5ffed822 Pull request #7: QFX-3714 S3插件 copy重写 4 years ago
Seth.Tian 2d967fa5fe QFX-3714 update:重写s3的copy方法 4 years ago
  1. 4
      .gitignore
  2. 1
      build.gradle
  3. 123
      build.xml
  4. 318
      front/bundle.js
  5. 10
      front/gulpfile.js
  6. 13
      front/package.json
  7. BIN
      lib/aws-java-sdk-core-1.11.801.jar
  8. BIN
      lib/aws-java-sdk-core-1.12.435.jar
  9. BIN
      lib/aws-java-sdk-kms-1.11.801.jar
  10. BIN
      lib/aws-java-sdk-kms-1.12.435.jar
  11. BIN
      lib/aws-java-sdk-s3-1.11.801.jar
  12. BIN
      lib/aws-java-sdk-s3-1.12.435.jar
  13. BIN
      lib/httpclient-4.5.9.jar
  14. BIN
      lib/jackson-annotations-2.14.1.jar
  15. BIN
      lib/jackson-annotations-2.6.0.jar
  16. BIN
      lib/jackson-core-2.14.1.jar
  17. BIN
      lib/jackson-core-2.6.7.jar
  18. BIN
      lib/jackson-databind-2.14.1.jar
  19. BIN
      lib/jackson-databind-2.6.7.3.jar
  20. BIN
      lib/jackson-dataformat-cbor-2.14.1.jar
  21. BIN
      lib/jackson-dataformat-cbor-2.6.7.jar
  22. 23
      plugin.xml
  23. 4
      src/main/java/com/fanruan/fs/s3/repository/S3FileServerResource.java
  24. 70
      src/main/java/com/fanruan/fs/s3/repository/core/S3Config.java
  25. 55
      src/main/java/com/fanruan/fs/s3/repository/core/S3RepositoryFactory.java
  26. 423
      src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java
  27. 5
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3.properties
  28. 11
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3_en_US.properties
  29. 9
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3_ja_JP.properties
  30. 9
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3_ko_KR.properties
  31. 11
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3_zh_CN.properties
  32. 9
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3_zh_TW.properties
  33. 192
      src/main/resources/com/fanruan/fs/s3/repository/web/js/bundle.js

4
.gitignore vendored

@ -7,6 +7,4 @@ target/
build
local.properties
classes/
transform-classes/
node_modules
yarn.lock
transform-classes/

1
build.gradle

@ -1,4 +1,3 @@
apply plugin: 'java'

123
build.xml

@ -1,123 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="jar" name="plugin-repository-s3">
<!-- JDK路径,根据自己机器上实际位置修改-->
<property name="jdk.home" value="/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home"/>
<property name="libs" value="${basedir}/lib"/>
<property name="publicLibs" value=""/>
<property name="destLoc" value="."/>
<property name="classes" value="classes"/>
<xmlproperty file="${basedir}/plugin.xml"/>
<property name="current-version" value="${plugin.version}"/>
<!-- 插件版本-->
<property name="plugin-version" value="${current-version}"/>
<!-- 插件名字-->
<property name="plugin-name" value="s3-repository"/>
<property name="plugin-jar" value="fr-plugin-${plugin-name}-${plugin-version}.jar"/>
<target name="prepare">
<delete dir="${classes}"/>
<delete dir="fr-plugin-${plugin-name}-${plugin-version}"/>
<xmlproperty file="${basedir}/plugin.xml"/>
<delete dir="${destLoc}/${plugin.name}"/>
</target>
<path id="compile.classpath">
<fileset dir="${libs}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${publicLibs}">
<include name="**/*.jar"/>
</fileset>
</path>
<patternset id="resources4Jar">
<exclude name="**/.settings/**"/>
<exclude name=".classpath"/>
<exclude name=".project"/>
<exclude name="**/*.java"/>
<exclude name="**/*.db"/>
<exclude name="**/*.g"/>
<exclude name="**/package.html"/>
</patternset>
<target name="copy_resources">
<echo message="从${resources_from}拷贝图片,JS,CSS等资源文件"/>
<delete dir="tmp"/>
<copy todir="tmp">
<fileset dir="${resources_from}/src/main/resources">
<patternset refid="resources4Jar"/>
</fileset>
</copy>
<copy todir="${classes}">
<fileset dir="tmp"/>
</copy>
<delete dir="tmp"/>
</target>
<target name="compile_javas">
<echo message="编译${compile_files}下的Java文件"/>
<javac destdir="${classes}" debug="false" optimize="on" source="${source_jdk_version}"
target="${target_jdk_version}"
fork="true" memoryMaximumSize="512m" listfiles="false" srcdir="${basedir}"
executable="${compile_jdk_version}/bin/javac">
<src path="${basedir}/src/main/java"/>
<exclude name="**/.svn/**"/>
<compilerarg line="-encoding UTF8 "/>
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="jar_classes">
<echo message="打Jar包:${jar_name}"/>
<delete file="${basedir}/${jar_name}"/>
<jar jarfile="${basedir}/${jar_name}">
<fileset dir="${classes}">
</fileset>
</jar>
</target>
<target name="super_jar" depends="prepare">
<antcall target="copy_resources">
<param name="resources_from" value="${basedir}"/>
</antcall>
<antcall target="compile_javas">
<param name="source_jdk_version" value="1.8"/>
<param name="target_jdk_version" value="1.8"/>
<param name="compile_jdk_version" value="${jdk.home}"/>
<param name="compile_files" value="${basedir}/src"/>
</antcall>
<echo message="compile plugin success!"/>
<antcall target="jar_classes">
<param name="jar_name" value="${plugin-jar}"/>
</antcall>
<delete dir="${classes}"/>
</target>
<target name="jar" depends="super_jar">
<antcall target="zip"/>
</target>
<target name="zip">
<property name="plugin-folder" value="fr-plugin-${plugin-name}-${plugin-version}"/>
<echo message="----------zip files----------"/>
<mkdir dir="${plugin-folder}"/>
<copy todir="${plugin-folder}">
<fileset dir=".">
<include name="${plugin-jar}"/>
<include name="plugin.xml"/>
</fileset>
<fileset dir="${libs}">
<include name="*.jar"/>
<include name="*.dll"/>
</fileset>
</copy>
<zip destfile="${basedir}/${plugin-folder}.zip" basedir=".">
<include name="${plugin-folder}/*.jar"/>
<include name="${plugin-folder}/*.dll"/>
<include name="${plugin-folder}/plugin.xml"/>
</zip>
<xmlproperty file="${basedir}/plugin.xml"/>
<move file="${plugin-folder}.zip" todir="${destLoc}/${plugin.name}"/>
<delete dir="${plugin-folder}"/>
</target>
</project>

318
front/bundle.js

@ -1,318 +0,0 @@
BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
items.push({
value: "S3", // 地址栏显示的hash值
id: "decision-intelligence-cluster-file-s3", // id
text: "S3", // 文字
cardType: "dec.intelligence.cluster.file.s3",
workRoot: false,
});
return items;
});
!(function () {
var LABEL_WIDTH = 107, EDITOR_WIDTH = 393;
var S3 = BI.inherit(BI.Widget, {
props: {
baseCls: "dec-cluster-ftp",
value: {},
},
_store: function () {
return BI.Models.getModel("dec.model.intelligence.cluster.file.s3", {
value: this.options.value,
});
},
watch: {
isOpen: function (v) {
this.toggle.setVisible(v);
}
},
render: function () {
var self = this, o = this.options;
return {
type: "bi.vertical",
tgap: 15,
items: [
{
type: "dec.label.editor.item",
textWidth: LABEL_WIDTH,
editorWidth: EDITOR_WIDTH,
watermark: BI.i18nText("Plugin-S3_Input"),
text: BI.i18nText("Plugin-S3_End_Point"),
value: this.model.endPoint,
el: {
disabled: !o.editable,
},
ref: function (_ref) {
self.endPointRow = _ref;
},
listeners: [{
eventName: BI.Editor.EVENT_CHANGE,
action: function () {
self.store.setEndPoint(this.getValue());
},
}],
}, {
type: "dec.label.editor.item",
textWidth: LABEL_WIDTH,
editorWidth: EDITOR_WIDTH,
watermark: BI.i18nText("Plugin-S3_Input"),
text: BI.i18nText("Plugin-S3_Region"),
value: this.model.region,
el: {
disabled: !o.editable,
},
ref: function (_ref) {
self.regionRow = _ref;
},
listeners: [{
eventName: BI.Editor.EVENT_CHANGE,
action: function () {
self.store.setRegion(this.getValue());
},
}],
}, {
type: "dec.label.editor.item",
textWidth: LABEL_WIDTH,
editorWidth: EDITOR_WIDTH,
watermark: BI.i18nText("Plugin-S3_Input"),
text: BI.i18nText("Plugin-S3_Access_Key_Id"),
value: this.model.accessKeyId,
el: {
disabled: !o.editable,
},
ref: function (_ref) {
self.portRow = _ref;
},
listeners: [{
eventName: BI.Editor.EVENT_CHANGE,
action: function () {
self.store.setAccessKeyId(this.getValue());
},
}],
},
{
type: "dec.common.cipher.editor",
textWidth: LABEL_WIDTH,
editorWidth: EDITOR_WIDTH,
watermark: BI.i18nText("Plugin-S3_Access_Key_Secret"),
text: BI.i18nText("Plugin-S3_Access_Key_Secret"),
value: this.model.password,
el: {
disabled: !o.editable,
},
ref: function (_ref) {
self.passwordRow = _ref;
},
},
{
type: "dec.label.editor.item",
textWidth: LABEL_WIDTH,
editorWidth: EDITOR_WIDTH,
watermark: BI.i18nText("Plugin-S3_Bucket"),
text: BI.i18nText("Plugin-S3_Bucket"),
value: this.model.bucket,
el: {
disabled: !o.editable,
},
listeners: [{
eventName: BI.Editor.EVENT_CHANGE,
action: function () {
self.store.setBucket(this.getValue());
},
}],
},
{
type: "dec.label.editor.item",
el: {
disabled: !o.editable,
},
textWidth: LABEL_WIDTH,
editorWidth: EDITOR_WIDTH,
watermark: BI.i18nText("Dec-Please_Input"),
text: BI.i18nText("Dec-Basic_Path"),
value: this.model.workRoot,
ref: function (_ref) {
self.filePathRow = _ref;
},
}, {
type: "bi.vertical_adapt",
items: [{
type: "bi.icon_change_button",
iconCls: this.model.isOpen ? "expander-down-font" : "expander-right-font",
ref: (_ref) => {
this.OtherConfigButton = _ref;
},
handler: () => {
this.store.setIsOpen(!this.model.isOpen);
this.OtherConfigButton.setIcon(this.model.isOpen ? "expander-down-font" : "expander-right-font");
}
}, {
type: "bi.text_button",
text: BI.i18nText('Plugin-S3_Other_Config'),
handler: () => {
this.store.setIsOpen(!this.model.isOpen);
this.OtherConfigButton.setIcon(this.model.isOpen ? "expander-down-font" : "expander-right-font");
}
}]
}, {
type: 'bi.vertical',
ref: (_ref) => {
this.toggle = _ref;
},
invisible: () => !this.model.isOpen,
items: [{
type: "dec.label.editor.item",
textWidth: LABEL_WIDTH,
editorWidth: EDITOR_WIDTH,
watermark: BI.i18nText("Plugin-S3_Input"),
text: "PathStyleAccess",
value: this.model.enablePathStyleAccess,
ref: function (_ref) {
self.enablePathStyleAccessRow = _ref;
},
el: {
disabled: !o.editable,
},
listeners: [{
eventName: BI.Editor.EVENT_CHANGE,
action: function () {
self.store.setEnablePathStyleAccess(this.getValue());
}
}]
}, {
type: "dec.label.editor.item",
textWidth: LABEL_WIDTH,
editorWidth: EDITOR_WIDTH,
watermark: BI.i18nText("Plugin-S3_Input"),
text: "SignerOverride",
value: this.model.signerOverride,
el: {
disabled: !o.editable,
},
tgap: 15,
listeners: [{
eventName: BI.Editor.EVENT_CHANGE,
action: function () {
self.store.setSignerOverride(this.getValue());
}
}]
}],
}
]
};
},
getValue: function () {
var enablePathStyleAccess = false;
if (this.model.enablePathStyleAccess === 'true') {
enablePathStyleAccess = true;
}
return {
endPoint: this.model.endPoint,
region: this.model.region,
accessKeyId: this.model.accessKeyId,
password: this.passwordRow.getCipher(),
bucket: this.model.bucket,
workRoot: this.filePathRow.getValue(),
enablePathStyleAccess,
signerOverride: this.model.signerOverride,
};
},
validation: function () {
var valid = true;
var path = this.filePathRow.getValue();
if (Dec.Utils.strLength(path) > DecCst.STRING_SHORT_TEXT_LENGTH) {
this.filePathRow.showError(BI.i18nText("Dec-Error_Length_Greater_Than_Short_Text"));
valid = false;
}
if (BI.startWith(path, "/") || !BI.endWith(path, "/")) {
this.filePathRow.showError(BI.i18nText("Dec-Error_Start_With_Slash_Or_End_Without_Slash"));
valid = false;
}
if (!BI.isKey(path)) {
this.filePathRow.showError(BI.i18nText("Dec-Error_Null"));
valid = false;
}
if (!(this.model.enablePathStyleAccess === 'false' || this.model.enablePathStyleAccess === 'true')) {
this.enablePathStyleAccessRow.showError(BI.i18nText("Plugin-S3_EnablePathStyleAccess_Error_Tip"));
valid = false;
}
return valid;
},
});
BI.shortcut("dec.intelligence.cluster.file.s3", S3);
}());
!(function () {
var Model = BI.inherit(Fix.Model, {
state: function () {
var val = this.options.value;
return {
endPoint: val.endPoint,
region: val.region,
accessKeyId: val.accessKeyId,
password: val.password,
bucket: val.bucket,
workRoot: val.workRoot,
isOpen: false,
enablePathStyleAccess: 'false',
signerOverride: "",
};
},
computed: {
encodingArray: function () {
return BI.map(DecCst.EncodeConstants.ENCODING_ARRAY, function (i, v) {
return {
value: v,
};
});
},
},
actions: {
setEndPoint: function (v) {
this.model.endPoint = v;
},
setRegion: function (v) {
this.model.region = v;
},
setAccessKeyId: function (v) {
this.model.accessKeyId = v;
},
setBucket: function (v) {
this.model.bucket = v;
},
setEnablePathStyleAccess: function (v) {
this.model.enablePathStyleAccess = v;
},
setSignerOverride: function (v) {
this.model.signerOverride = v;
},
setIsOpen: function (v) {
this.model.isOpen = v;
},
},
});
BI.model("dec.model.intelligence.cluster.file.s3", Model);
}());

10
front/gulpfile.js

@ -1,10 +0,0 @@
const gulp = require('gulp');
const uglify = require('gulp-uglify');
function build() {
return gulp.src('./bundle.js')
.pipe(uglify())
.pipe(gulp.dest('../src/main/resources/com/fanruan/fs/s3/repository/web/js'));
}
exports.default = build;

13
front/package.json

@ -1,13 +0,0 @@
{
"name": "front",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"build": "gulp"
},
"dependencies": {
"gulp": "^4.0.2",
"gulp-uglify": "^3.0.2"
}
}

BIN
lib/aws-java-sdk-core-1.11.801.jar

Binary file not shown.

BIN
lib/aws-java-sdk-core-1.12.435.jar

Binary file not shown.

BIN
lib/aws-java-sdk-kms-1.11.801.jar

Binary file not shown.

BIN
lib/aws-java-sdk-kms-1.12.435.jar

Binary file not shown.

BIN
lib/aws-java-sdk-s3-1.11.801.jar

Binary file not shown.

BIN
lib/aws-java-sdk-s3-1.12.435.jar

Binary file not shown.

BIN
lib/httpclient-4.5.13.jar → lib/httpclient-4.5.9.jar

Binary file not shown.

BIN
lib/jackson-annotations-2.14.1.jar

Binary file not shown.

BIN
lib/jackson-annotations-2.6.0.jar

Binary file not shown.

BIN
lib/jackson-core-2.14.1.jar

Binary file not shown.

BIN
lib/jackson-core-2.6.7.jar

Binary file not shown.

BIN
lib/jackson-databind-2.14.1.jar

Binary file not shown.

BIN
lib/jackson-databind-2.6.7.3.jar

Binary file not shown.

BIN
lib/jackson-dataformat-cbor-2.14.1.jar

Binary file not shown.

BIN
lib/jackson-dataformat-cbor-2.6.7.jar

Binary file not shown.

23
plugin.xml

@ -5,28 +5,13 @@
<main-package>com.fanruan.fs</main-package>
<active>yes</active>
<hidden>no</hidden>
<version>1.4.1</version>
<env-version>10.0~10.0</env-version>
<jartime>2021-03-11</jartime>
<version>2.2</version>
<env-version>10.0</env-version>
<jartime>2020-01-27</jartime>
<vendor>richie</vendor>
<description><![CDATA[使用支持S3协议的云存储文件系统作为文件服务器。]]></description>
<change-notes><![CDATA[
[2023-11-21]小文件不使用分片上传。 <br/>
[2023-08-08]支持分片上传,模板保存问题修复。 <br/>
[2023-06-30]修复默认配置获取错误的问题,过滤有问题的路径。 <br/>
[2023-03-28]第三方组件升级。 <br/>
[2023-01-03]优化写文件性能; 修复文件太多显示不全的问题。<br/>
[2022-09-22]第三方组件升级。 <br/>
[2022-07-25]修复http无法连接,而https和缺省的时候正常<br/>
[2022-06-30]新增enablePathStyleAccess、signerOverride后台配置<br/>
[2022-06-14]第三方组件升级。 <br/>
[2022-03-10]第三方组件升级。 <br/>
[2021-07-16]提供韩文、日文、繁体等国际化文件。 <br/>
[2021-04-23]copyFile接口兼容。 <br/>
[2021-03-30]修复copy文件耗时问题。<br/>
[2021-01-28]修复备份还原S3报警告问题。<br/>
[2021-01-24]修复定时调度结果文件预览失败。<br/>
[2021-01-20]正式作为官方插件维护。<br/>
[2021-01-11]重写copy实现。<br/>
[2020-12-16]修复远程设计新增、修改模板问题。<br/>
[2020-10-29]修复连接不释放问题。<br/>
[2020-08-17]修复key不存在时报错的问题。<br/>

4
src/main/java/com/fanruan/fs/s3/repository/S3FileServerResource.java

@ -1,7 +1,7 @@
package com.fanruan.fs.s3.repository;
import com.fr.decision.fun.impl.AbstractWebResourceProvider;
import com.fr.decision.web.CommonComponent;
import com.fr.decision.web.MainComponent;
import com.fanruan.fs.s3.repository.web.S3FileServerComponent;
import com.fr.web.struct.Atom;
@ -14,7 +14,7 @@ public class S3FileServerResource extends AbstractWebResourceProvider {
@Override
public Atom attach() {
return CommonComponent.KEY;
return MainComponent.KEY;
}
@Override

70
src/main/java/com/fanruan/fs/s3/repository/core/S3Config.java

@ -1,8 +1,8 @@
package com.fanruan.fs.s3.repository.core;
import com.fanruan.api.conf.HolderKit;
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;
@ -21,25 +21,19 @@ public class S3Config extends CommonRepoConfig {
}
@Identifier("endPoint")
private Conf<String> endPoint = HolderKit.simple(StringUtils.EMPTY);
private Conf<String> endPoint = Holders.simple(StringUtils.EMPTY);
@Identifier("region")
private Conf<String> region = HolderKit.simple(StringUtils.EMPTY);
private Conf<String> region = Holders.simple(StringUtils.EMPTY);
@Identifier("accessKeyId")
private Conf<String> accessKeyId = HolderKit.simple(StringUtils.EMPTY);
private Conf<String> accessKeyId = Holders.simple(StringUtils.EMPTY);
@Identifier("bucket")
private Conf<String> bucket = HolderKit.simple(StringUtils.EMPTY);
@Identifier("enablePathStyleAccess")
private Conf<Boolean> enablePathStyleAccess = HolderKit.simple(false);
@Identifier("signerOverride")
private Conf<String> signerOverride = HolderKit.simple(StringUtils.EMPTY);
@Identifier("accessKeySecret")
private Conf<String> accessKeySecret = Holders.simple(StringUtils.EMPTY);
@Identifier("maxConnections")
private Conf<Integer> maxConnections = HolderKit.simple(200);
@Identifier("bucket")
private Conf<String> bucket = Holders.simple(StringUtils.EMPTY);
@GetConfig("endPoint")
public String getEndPoint() {
@ -71,6 +65,16 @@ public class S3Config extends CommonRepoConfig {
this.accessKeyId.set(accessKeyId);
}
@GetConfig("accessKeySecret")
public String getAccessKeySecret() {
return accessKeySecret.get();
}
@SetConfig("accessKeySecret")
public void setAccessKeySecret(String accessKeySecret) {
this.accessKeySecret.set(accessKeySecret);
}
@GetConfig("bucket")
public String getBucket() {
return bucket.get();
@ -81,36 +85,6 @@ public class S3Config extends CommonRepoConfig {
this.bucket.set(bucket);
}
@GetConfig("enablePathStyleAccess")
public boolean isEnablePathStyleAccess() {
return enablePathStyleAccess.get();
}
@SetConfig("enablePathStyleAccess")
public void setEnablePathStyleAccess(boolean enablePathStyleAccess) {
this.enablePathStyleAccess.set(enablePathStyleAccess);
}
@GetConfig("signerOverride")
public String getSignerOverride() {
return signerOverride.get();
}
@SetConfig("signerOverride")
public void setSignerOverride(String signerOverride) {
this.signerOverride.set(signerOverride);
}
@GetConfig("maxConnections")
public int getMaxConnections() {
return maxConnections.get();
}
@SetConfig("maxConnections")
public void setMaxConnections(int maxConnections) {
this.maxConnections.set(maxConnections);
}
@Override
public void update(String key) {
super.update(key);
@ -119,10 +93,8 @@ public class S3Config extends CommonRepoConfig {
this.setEndPoint(newConfig.getEndPoint());
this.setRegion(newConfig.getRegion());
this.setAccessKeyId(newConfig.getAccessKeyId());
this.setAccessKeySecret(newConfig.getAccessKeySecret());
this.setBucket(newConfig.getBucket());
this.setEnablePathStyleAccess(newConfig.isEnablePathStyleAccess());
this.setSignerOverride(newConfig.getSignerOverride());
this.setMaxConnections(newConfig.getMaxConnections());
}
}
@ -132,10 +104,8 @@ public class S3Config extends CommonRepoConfig {
cloned.endPoint = (Conf<String>) endPoint.clone();
cloned.region = (Conf<String>) region.clone();
cloned.accessKeyId = (Conf<String>) accessKeyId.clone();
cloned.accessKeySecret = (Conf<String>) accessKeySecret.clone();
cloned.bucket = (Conf<String>) bucket.clone();
cloned.enablePathStyleAccess = (Conf<Boolean>) enablePathStyleAccess.clone();
cloned.signerOverride = (Conf<String>) signerOverride.clone();
cloned.maxConnections = (Conf<Integer>) maxConnections.clone();
return cloned;
}
}

55
src/main/java/com/fanruan/fs/s3/repository/core/S3RepositoryFactory.java

@ -1,19 +1,19 @@
package com.fanruan.fs.s3.repository.core;
import com.amazonaws.ClientConfiguration;
import com.amazonaws.Protocol;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
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.S3Object;
import com.amazonaws.services.s3.model.S3ObjectInputStream;
import com.fanruan.api.log.LogKit;
import com.fr.io.base.provider.impl.ConfigRepositoryFactory;
import com.fr.io.context.info.RepositoryProfile;
import com.fr.io.repository.ResourceRepository;
import com.fr.stable.StringUtils;
import com.fr.stable.AssistUtils;
import static com.fanruan.fs.s3.repository.core.S3ResourceRepository.HTTP;
import java.io.IOException;
/**
* @author richie
@ -23,6 +23,8 @@ import static com.fanruan.fs.s3.repository.core.S3ResourceRepository.HTTP;
public class S3RepositoryFactory extends ConfigRepositoryFactory<S3Config> {
static final String IDENTITY = "S3";
private static final String TEST_KEY = "test_key";
private static final String TEST_CONTENT = "test content";
public S3RepositoryFactory() {
super(IDENTITY);
@ -40,39 +42,40 @@ public class S3RepositoryFactory extends ConfigRepositoryFactory<S3Config> {
@Override
public boolean verifyConfig(S3Config config) {
AmazonS3 s3 = null;
try {
BasicAWSCredentials credentials = new BasicAWSCredentials(config.getAccessKeyId(), config.getPassword());
AmazonS3ClientBuilder amazonS3ClientBuilder = AmazonS3ClientBuilder.standard()
BasicAWSCredentials credentials = new BasicAWSCredentials(config.getAccessKeyId(), config.getAccessKeySecret());
AmazonS3 s3 = AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(config.getEndPoint(), config.getRegion()))
.withCredentials(new AWSStaticCredentialsProvider(credentials)).disableChunkedEncoding();
if (config.isEnablePathStyleAccess()) {
amazonS3ClientBuilder = amazonS3ClientBuilder.enablePathStyleAccess();
.withCredentials(new AWSStaticCredentialsProvider(credentials)).build();
// listObjects方法存在问题,如果key中包含URL编码的内容,将会抛异常,修改为读写验证是否可用
s3.putObject(config.getBucket(), TEST_KEY, TEST_CONTENT);
try (S3Object object = s3.getObject(config.getBucket(), TEST_KEY)) {
final String content = getContent(object);
s3.deleteObject(config.getBucket(), TEST_KEY);
return AssistUtils.equals(TEST_CONTENT, content);
}
ClientConfiguration clientConfiguration = new ClientConfiguration();
if (StringUtils.isNotEmpty(config.getSignerOverride())) {
clientConfiguration.setSignerOverride(config.getSignerOverride());
}
LogKit.debug("[S3] endpoint is {}", config.getEndPoint());
if (config.getEndPoint().startsWith(HTTP)) {
clientConfiguration.setProtocol(Protocol.HTTP);
}
amazonS3ClientBuilder = amazonS3ClientBuilder.withClientConfiguration(clientConfiguration);
s3 = amazonS3ClientBuilder.build();
s3.listObjects(config.getBucket());
} catch (Exception e) {
LogKit.error(e.getMessage(), e);
return false;
} finally {
if (s3 != null) {
s3.shutdown();
}
}
return true;
}
@Override
public ResourceRepository produce(String repoName, String workRoot, S3Config config) {
return new S3ResourceRepository(repoName, workRoot, config);
}
private String getContent(S3Object object) {
final StringBuilder stringBuilder = new StringBuilder();
try (S3ObjectInputStream objectContent = object.getObjectContent()) {
final byte[] bytes = new byte[4096];
int i = 0;
while ((i = objectContent.read(bytes)) > -1) {
stringBuilder.append(new String(bytes, 0, i));
}
} catch (IOException e) {
LogKit.error(e.getMessage(), e);
}
return stringBuilder.toString();
}
}

423
src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java

@ -1,39 +1,31 @@
package com.fanruan.fs.s3.repository.core;
import com.amazonaws.ClientConfiguration;
import com.amazonaws.Protocol;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
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.CompleteMultipartUploadRequest;
import com.amazonaws.services.s3.model.DeleteObjectsRequest;
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.InitiateMultipartUploadRequest;
import com.amazonaws.services.s3.model.InitiateMultipartUploadResult;
import com.amazonaws.services.s3.model.ListObjectsRequest;
import com.amazonaws.services.s3.model.ObjectListing;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.PartETag;
import com.amazonaws.services.s3.model.PutObjectRequest;
import com.amazonaws.services.s3.model.S3Object;
import com.amazonaws.services.s3.model.S3ObjectSummary;
import com.amazonaws.services.s3.model.UploadPartRequest;
import com.amazonaws.services.s3.model.UploadPartResult;
import com.amazonaws.util.IOUtils;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.StringKit;
import com.fr.common.util.Strings;
import com.fr.io.repository.FineFileEntry;
import com.fr.io.repository.base.BaseResourceRepository;
import com.fr.io.utils.ResourceIOUtils;
import com.fr.stable.ArrayUtils;
import com.fr.stable.AssistUtils;
import com.fr.stable.Filter;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.io.output.NullOutputStream;
import com.fr.stable.StableUtils;
import com.fr.workspace.resource.ResourceIOException;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
@ -47,14 +39,8 @@ import java.util.List;
*/
public class S3ResourceRepository extends BaseResourceRepository {
private static final int PAGE_SIZE = 1000;
private static final int PART_SIZE = 5 * 1024 * 1024;
private static final int MULTIPART_UPLOAD_LIMIT = 20 * PART_SIZE;
private static final String DELIMITER = "/";
public static final String HTTP = "http:";
private static final String CHAR_SET = "UTF-8";
private final AmazonS3 s3;
private final String bucket;
@ -62,25 +48,10 @@ public class S3ResourceRepository extends BaseResourceRepository {
public S3ResourceRepository(String repoName, String workRoot, S3Config config) {
super(repoName, workRoot);
BasicAWSCredentials credentials = new BasicAWSCredentials(config.getAccessKeyId(), config.getPassword());
AmazonS3ClientBuilder amazonS3ClientBuilder = AmazonS3ClientBuilder.standard()
BasicAWSCredentials credentials = new BasicAWSCredentials(config.getAccessKeyId(), config.getAccessKeySecret());
this.s3 = AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(config.getEndPoint(), config.getRegion()))
.withCredentials(new AWSStaticCredentialsProvider(credentials)).disableChunkedEncoding();
if (config.isEnablePathStyleAccess()) {
amazonS3ClientBuilder = amazonS3ClientBuilder.enablePathStyleAccess();
}
ClientConfiguration clientConfiguration = new ClientConfiguration();
clientConfiguration.setMaxConnections(config.getMaxConnections());
LogKit.info("Max connections is {}!", clientConfiguration.getMaxConnections());
if (StringUtils.isNotEmpty(config.getSignerOverride())) {
clientConfiguration.setSignerOverride(config.getSignerOverride());
}
LogKit.debug("[S3] endpoint is {}", config.getEndPoint());
if (config.getEndPoint().startsWith(HTTP)) {
clientConfiguration.setProtocol(Protocol.HTTP);
}
amazonS3ClientBuilder = amazonS3ClientBuilder.withClientConfiguration(clientConfiguration);
this.s3 = amazonS3ClientBuilder.build();
.withCredentials(new AWSStaticCredentialsProvider(credentials)).build();
this.bucket = config.getBucket();
}
@ -91,9 +62,14 @@ public class S3ResourceRepository extends BaseResourceRepository {
@Override
public FineFileEntry getEntry(String path) {
GetObjectRequest request = new GetObjectRequest(bucket, path);
try {
ObjectMetadata metadata = s3.getObjectMetadata(bucket, path);
return s3Object2FileEntry(metadata, path);
S3Object s3Object = s3.getObject(request);
try {
return s3Object2FileEntry(s3Object, path);
} finally {
s3Object.close();
}
} catch (Exception e) {
LogKit.info("{} not exist!", path);
}
@ -110,15 +86,6 @@ public class S3ResourceRepository extends BaseResourceRepository {
ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucket)
.withPrefix(dir).withDelimiter(DELIMITER);
ObjectListing objectListing = s3.listObjects(listObjectsRequest);
collectFileEntry(dir, result, objectListing);
while (objectListing.isTruncated()) {
objectListing = s3.listNextBatchOfObjects(objectListing);
collectFileEntry(dir, result, objectListing);
}
return result.toArray(new FineFileEntry[0]);
}
private void collectFileEntry(String dir, List<FineFileEntry> result, ObjectListing objectListing) {
for (S3ObjectSummary summary : objectListing.getObjectSummaries()) {
String key = summary.getKey();
if (!key.endsWith(DELIMITER)) {
@ -126,12 +93,57 @@ public class S3ResourceRepository extends BaseResourceRepository {
}
}
for (String prefix : objectListing.getCommonPrefixes()) {
if (StringUtils.isNotEmpty(prefix.substring(dir.length()).replaceAll(DELIMITER, StringUtils.EMPTY))) {
FineFileEntry entry = new FineFileEntry(prefix);
entry.setDirectory(true);
result.add(entry);
FineFileEntry entry = new FineFileEntry(prefix);
entry.setDirectory(true);
result.add(entry);
}
return result.toArray(new FineFileEntry[0]);
}
@Override
public boolean copy(String source, String target) throws ResourceIOException {
if (AssistUtils.equals(source, target)
|| Strings.isEmpty(source)
|| Strings.isEmpty(target)) {
return true;
}
boolean result = true;
if (this.isDirectory(source)) {
final String[] list = list(source);
if (!ArrayUtils.isEmpty(list)) {
for (String s : list) {
String targetKey = StableUtils.pathJoin(target, s);
String sourceKey = StableUtils.pathJoin(source, s);
result = result && this.copy(sourceKey, targetKey);
}
}
} else {
try {
s3.copyObject(bucket, source, bucket, target);
return true;
} catch (Exception e) {
LogKit.error(e, "copy {} to {} failed, because : ", source, target, e.getMessage());
return false;
}
}
return result;
}
private FineFileEntry s3Object2FileEntry(S3ObjectSummary s3Object, String path) {
FineFileEntry entry = new FineFileEntry(path);
entry.setDirectory(s3Object.getKey().endsWith("/"));
entry.setSize(s3Object.getSize());
entry.setTimestamp(s3Object.getLastModified().getTime());
return entry;
}
private FineFileEntry s3Object2FileEntry(S3Object s3Object, String path) {
FineFileEntry entry = new FineFileEntry(path);
entry.setDirectory(s3Object.getKey().endsWith("/"));
entry.setSize(s3Object.getObjectMetadata().getContentLength());
entry.setTimestamp(s3Object.getObjectMetadata().getLastModified().getTime());
return entry;
}
@Override
@ -145,104 +157,36 @@ public class S3ResourceRepository extends BaseResourceRepository {
try {
return s3.getObject(request).getObjectContent();
} catch (Exception e) {
LogKit.error("[S3] Failed to read file {}", filePath);
LogKit.error(e.getMessage(), e);
return new ByteArrayInputStream(new byte[0]);
}
}
@Override
public void write(String path, byte[] data) {
int length = data.length;
if (length > MULTIPART_UPLOAD_LIMIT) {
multipartUpload(path, new ByteArrayInputStream(data));
} else {
ObjectMetadata metadata;
try {
metadata = s3.getObjectMetadata(bucket, path);
} catch (Exception e) {
metadata = new ObjectMetadata();
String mimeType = URLConnection.guessContentTypeFromName(path);
if (mimeType != null) {
metadata.setContentType(mimeType);
}
}
if (metadata != null) {
metadata.setContentLength(length);
}
s3.putObject(bucket, path, new ByteArrayInputStream(data), metadata);
}
}
@Override
public void write(String path, InputStream inputStream) throws ResourceIOException {
long dataLength = 0;
ObjectMetadata metadata;
try {
dataLength = inputStream.available();
} catch (IOException e) {
LogKit.error(e.getMessage(), e);
metadata = s3.getObjectMetadata(bucket, path);
} catch (Exception e) {
metadata = new ObjectMetadata();
String mimeType = URLConnection.guessContentTypeFromName(path);
if (mimeType != null) {
metadata.setContentType(mimeType);
}
metadata.setContentLength(data.length);
}
//超过一定大小才使用分片上传,小文件来说,网络传输时间可能较短,且上传失败的风险相对较低。
//在网络稳定的情况下,使用分片上传可能没有太多的优势,反而增加了额外开销和复杂性
if (dataLength > MULTIPART_UPLOAD_LIMIT) {
multipartUpload(path, inputStream);
} else {
super.write(path, inputStream);
if (metadata != null) {
metadata.setContentLength(data.length);
}
s3.putObject(bucket, path, new ByteArrayInputStream(data), metadata);
}
private void multipartUpload(String path, InputStream inputStream) {
try {
// Step 1: 初始化分片上传
InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest(bucket, path);
InitiateMultipartUploadResult initResponse = s3.initiateMultipartUpload(initRequest);
String uploadId = initResponse.getUploadId();
// Step 2: 分片上传文件
List<PartETag> partETags = new ArrayList<>();
byte[] buffer = new byte[PART_SIZE];
int bytesRead;
int partNumber = 1;
while ((bytesRead = inputStream.read(buffer)) > 0) {
// 创建上传请求
UploadPartRequest uploadRequest = new UploadPartRequest()
.withBucketName(bucket)
.withKey(path)
.withUploadId(uploadId)
.withPartNumber(partNumber)
.withInputStream(new ByteArrayInputStream(buffer, 0, bytesRead))
.withPartSize(bytesRead);
// 上传分片
UploadPartResult uploadResult = s3.uploadPart(uploadRequest);
partETags.add(uploadResult.getPartETag());
partNumber++;
}
// Step 3: 完成分片上传
CompleteMultipartUploadRequest compRequest = new CompleteMultipartUploadRequest(bucket, path, uploadId, partETags);
s3.completeMultipartUpload(compRequest);
} catch (IOException e) {
throw new ResourceIOException(e);
} finally {
ResourceIOUtils.close(inputStream);
}
}
@Override
public boolean createFile(String path) {
String parent = path.substring(0, path.lastIndexOf(DELIMITER) + 1);
if (!dirExist(parent)) {
createDirectory(parent);
}
PutObjectRequest req = new PutObjectRequest(bucket, path, new ByteArrayInputStream(new byte[0]), buildEmptyMetadata());
PutObjectRequest request = new PutObjectRequest(bucket, path, new ByteArrayInputStream(new byte[0]), new ObjectMetadata());
try {
s3.putObject(req);
s3.putObject(request);
} catch (Exception e) {
LogKit.error("[S3] Failed to create file path {}", path);
return false;
}
return true;
@ -250,25 +194,10 @@ public class S3ResourceRepository extends BaseResourceRepository {
@Override
public boolean createDirectory(String path) {
if (!path.endsWith(DELIMITER)) {
path += DELIMITER;
}
String temp = path.substring(0, path.length() - 1);
String parent = temp.substring(0, temp.lastIndexOf(DELIMITER) + 1);
if (StringUtils.isEmpty(parent)) {
return true;
}
if (!dirExist(parent)) {
if (!createDirectory(parent)) {
return false;
}
}
PutObjectRequest req = new PutObjectRequest(bucket, path, new ByteArrayInputStream(new byte[0]), buildEmptyMetadata());
PutObjectRequest request = new PutObjectRequest(bucket, path + "/", new ByteArrayInputStream(new byte[0]), new ObjectMetadata());
try {
s3.putObject(req);
s3.putObject(request);
} catch (Exception e) {
LogKit.error("[S3] Failed to create parent path {}", path);
return false;
}
return true;
@ -277,54 +206,16 @@ public class S3ResourceRepository extends BaseResourceRepository {
@Override
public boolean delete(String path) {
try {
if (isDirectory(path)) {
if (!path.endsWith(DELIMITER)) {
path += DELIMITER;
}
deleteDirectory(path);
} else {
deleteFile(path);
}
s3.deleteObject(bucket, path);
} catch (Exception e) {
LogKit.error("[S3] delete {} failed, error message: {}", path, e.getMessage());
LogKit.error(e.getMessage(), e);
return false;
}
return true;
}
private void deleteFile(String path) throws Exception {
s3.deleteObject(bucket, path);
}
private void deleteDirectory(String path) throws Exception {
List<String> files = new ArrayList<>();
for (FineFileEntry fineFileEntry : listEntry(path)) {
if (fineFileEntry.isDirectory()) {
deleteDirectory(fineFileEntry.getPath());
} else {
files.add(fineFileEntry.getPath());
}
}
deleteFiles(files);
deleteFile(path);
}
private void deleteFiles(List<String> paths) throws Exception {
//最多只能同时指定1000个key
for (int i = 0; i < paths.size(); i = i + PAGE_SIZE) {
int toIndex = Math.min(i + PAGE_SIZE, paths.size());
DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest(bucket)
.withKeys(paths.subList(i, toIndex).toArray(new String[0]));
s3.deleteObjects(deleteObjectsRequest);
}
}
@Override
public boolean exist(String path) {
return fileExist(path) || (!path.endsWith(DELIMITER) && dirExist(path)) || isParentPathAbsent(path);
}
private boolean fileExist(String path) {
try {
return s3.doesObjectExist(bucket, path);
} catch (Exception e) {
@ -332,38 +223,6 @@ public class S3ResourceRepository extends BaseResourceRepository {
}
}
private boolean dirExist(String path) {
if (StringUtils.equals(path, DELIMITER)) {
return true;
}
if (!path.endsWith(DELIMITER)) {
path += DELIMITER;
}
return fileExist(path);
}
/**
* 如果存在文件创建了但是其父目录没有创建的场景为其递归创建对象返回创建结果
*/
private boolean isParentPathAbsent(String path) {
if (path.startsWith(DELIMITER)) {
path = path.substring(1);
}
if (path.endsWith(DELIMITER)) {
path = path.substring(0, path.length() - 1);
}
ObjectListing objectListing = s3.listObjects(
new ListObjectsRequest()
.withBucketName(bucket)
.withPrefix(path));
for (S3ObjectSummary summary : objectListing.getObjectSummaries()) {
if (summary.getKey().startsWith(path + DELIMITER)) {
return createDirectory(path);
}
}
return false;
}
@Override
public String[] list(String dir, final Filter<String> filter) {
List<String> result = new ArrayList<>();
@ -373,46 +232,45 @@ public class S3ResourceRepository extends BaseResourceRepository {
ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucket)
.withPrefix(dir).withDelimiter(DELIMITER);
ObjectListing objectListing = s3.listObjects(listObjectsRequest);
collectFileName(dir, result, objectListing);
while (objectListing.isTruncated()) {
objectListing = s3.listNextBatchOfObjects(objectListing);
collectFileName(dir, result, objectListing);
}
if (filter != null) {
return result.stream().filter(filter::accept).toArray(String[]::new);
}
return result.toArray(new String[0]);
}
private void collectFileName(String dir, List<String> result, ObjectListing objectListing) {
for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) {
String key = objectSummary.getKey();
if (StringKit.equals(key, dir)) {
continue;
String[] arr = objectSummary.getKey().split(DELIMITER);
String name = arr[arr.length - 1];
if (filter == null) {
result.add(name);
} else {
if (filter.accept(name)) {
result.add(name);
}
}
result.add(key.substring(key.lastIndexOf(DELIMITER) + 1));
}
for (String prefix : objectListing.getCommonPrefixes()) {
if (StringUtils.isNotEmpty(prefix.substring(dir.length()).replaceAll(DELIMITER, StringUtils.EMPTY))) {
String[] arr = prefix.split(DELIMITER);
String name = arr[arr.length - 1] + DELIMITER;
String[] arr = prefix.split(DELIMITER);
String name = arr[arr.length - 1] + DELIMITER;
if (filter == null) {
result.add(name);
} else {
if (filter.accept(name)) {
result.add(name);
}
}
}
return result.toArray(new String[0]);
}
@Override
public boolean isDirectory(String path) {
if (path.endsWith(DELIMITER)) {
return exist(path);
return true;
}
ObjectListing listing = s3.listObjects(bucket, path);
if (listing.getObjectSummaries().isEmpty()) {
return false;
}
if (listing.getObjectSummaries().size() > 1) {
return true;
} else {
ObjectListing listing = s3.listObjects(bucket, path);
List<S3ObjectSummary> objectSummaries = listing.getObjectSummaries();
if (objectSummaries.isEmpty()) {
return false;
}
String dirFormat = path + DELIMITER;
return objectSummaries.stream().anyMatch(s3ObjectSummary -> StringUtils.equals(s3ObjectSummary.getKey(), dirFormat));
S3ObjectSummary summary = listing.getObjectSummaries().get(0);
return !StringKit.equals(listing.getPrefix(), summary.getKey());
}
}
@ -422,8 +280,6 @@ public class S3ResourceRepository extends BaseResourceRepository {
S3Object s3Object = s3.getObject(bucket, path);
if (s3Object != null) {
try {
//s3Object要全部读完,否则会有警告
IOUtils.copy(s3Object.getObjectContent(), new NullOutputStream());
return s3Object.getObjectMetadata().getLastModified().getTime();
} finally {
s3Object.close();
@ -439,8 +295,14 @@ public class S3ResourceRepository extends BaseResourceRepository {
@Override
public long length(String path) {
try {
ObjectMetadata metadata = s3.getObjectMetadata(bucket, path);
return metadata.getContentLength();
S3Object s3Object = s3.getObject(bucket, path);
if (s3Object != null) {
try {
return s3Object.getObjectMetadata().getContentLength();
} finally {
s3Object.close();
}
}
} catch (Exception e) {
LogKit.info("{} not exist!", path);
}
@ -450,21 +312,16 @@ public class S3ResourceRepository extends BaseResourceRepository {
@Override
public boolean rename(String path, String newPath) throws ResourceIOException {
if (copy(path, newPath) && delete(path)) {
if (LogKit.isDebugEnabled()) {
LogKit.debug("[S3] rename {} to {} success.", path, newPath);
}
return true;
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;
}
LogKit.error("[S3] rename {} to {} failed.", path, newPath);
return false;
}
@Override
public boolean copyFile(String origPath, String desPath) throws ResourceIOException {
s3.copyObject(bucket, origPath, bucket, desPath);
return exist(desPath);
return true;
}
@Override
@ -477,30 +334,4 @@ public class S3ResourceRepository extends BaseResourceRepository {
return S3RepositoryFactory.IDENTITY;
}
/*--------------------------------------私有方法-----------------------------------------**/
private ObjectMetadata buildEmptyMetadata() {
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(0);
return metadata;
}
private FineFileEntry s3Object2FileEntry(S3ObjectSummary s3Object, String path) {
FineFileEntry entry = new FineFileEntry(path);
entry.setDirectory(s3Object.getKey().endsWith(DELIMITER));
entry.setSize(s3Object.getSize());
entry.setTimestamp(s3Object.getLastModified().getTime());
return entry;
}
private FineFileEntry s3Object2FileEntry(ObjectMetadata metadata, String path) {
FineFileEntry entry = new FineFileEntry(path);
entry.setDirectory(path.endsWith(DELIMITER));
entry.setSize(metadata.getContentLength());
entry.setTimestamp(metadata.getLastModified().getTime());
return entry;
}
}

5
src/main/resources/com/fanruan/fs/s3/repository/locale/s3.properties

@ -3,7 +3,4 @@ Plugin-S3_End_Point=Endpoint
Plugin-S3_Region=Region
Plugin-S3_Access_Key_Id=AccessKeyId
Plugin-S3_Access_Key_Secret=AccessKeySecret
Plugin-S3_Bucket=Bucket
Dec-Error_Start_With_Slash_Or_End_Without_Slash=The path cannot start with "/", but must end with "/"
Plugin-S3_Other_Config=
Plugin-S3_EnablePathStyleAccess_Error_Tip=
Plugin-S3_Bucket=Bucket

11
src/main/resources/com/fanruan/fs/s3/repository/locale/s3_en_US.properties

@ -1,9 +1,6 @@
Dec-Error_Start_With_Slash_Or_End_Without_Slash=The path cannot start with "/", but must end with "/"
Plugin-S3_Access_Key_Id=AccessKeyId
Plugin-S3_Access_Key_Secret=AccessKeySecret
Plugin-S3_Bucket=Bucket
Plugin-S3_Input=Please Input
Plugin-S3_End_Point=Endpoint
Plugin-S3_Input=Please input
Plugin-S3_Region=Region
Plugin-S3_Other_Config=
Plugin-S3_EnablePathStyleAccess_Error_Tip=
Plugin-S3_Access_Key_Id=AccessKeyId
Plugin-S3_Access_Key_Secret=AccessKeySecret
Plugin-S3_Bucket=Bucket

9
src/main/resources/com/fanruan/fs/s3/repository/locale/s3_ja_JP.properties

@ -1,9 +0,0 @@
Dec-Error_Start_With_Slash_Or_End_Without_Slash=\u30D1\u30B9\u306F\u300C/\u300D\u3067\u59CB\u307E\u308B\u3053\u3068\u304C\u3067\u304D\u306A\u3044\u3002\u300C/\u300D\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308B\u3002
Plugin-S3_Access_Key_Id=AccessKeyId
Plugin-S3_Access_Key_Secret=AccessKeySecret
Plugin-S3_Bucket=Bucket
Plugin-S3_End_Point=Endpoint
Plugin-S3_Input=\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002
Plugin-S3_Region=Region
Plugin-S3_Other_Config=
Plugin-S3_EnablePathStyleAccess_Error_Tip=

9
src/main/resources/com/fanruan/fs/s3/repository/locale/s3_ko_KR.properties

@ -1,9 +0,0 @@
Dec-Error_Start_With_Slash_Or_End_Without_Slash=
Plugin-S3_Access_Key_Id=
Plugin-S3_Access_Key_Secret=
Plugin-S3_Bucket=
Plugin-S3_End_Point=
Plugin-S3_Input=
Plugin-S3_Region=
Plugin-S3_Other_Config=
Plugin-S3_EnablePathStyleAccess_Error_Tip=

11
src/main/resources/com/fanruan/fs/s3/repository/locale/s3_zh_CN.properties

@ -1,9 +1,6 @@
Dec-Error_Start_With_Slash_Or_End_Without_Slash=\u8DEF\u5F84\u5F00\u5934\u4E0D\u80FD\u52A0\u659C\u6760\uFF0C\u5FC5\u987B\u4EE5\u659C\u6760\u7ED3\u5C3E
Plugin-S3_Access_Key_Id=AccessKeyId
Plugin-S3_Access_Key_Secret=AccessKeySecret
Plugin-S3_Bucket=Bucket
Plugin-S3_End_Point=Endpoint
Plugin-S3_Input=\u8BF7\u8F93\u5165
Plugin-S3_End_Point=Endpoint
Plugin-S3_Region=Region
Plugin-S3_Other_Config=\u66f4\u591a\u8bbe\u7f6e
Plugin-S3_EnablePathStyleAccess_Error_Tip=\u8bf7\u8f93\u5165true\u6216false
Plugin-S3_Access_Key_Id=AccessKeyId
Plugin-S3_Access_Key_Secret=AccessKeySecret
Plugin-S3_Bucket=Bucket

9
src/main/resources/com/fanruan/fs/s3/repository/locale/s3_zh_TW.properties

@ -1,9 +0,0 @@
Dec-Error_Start_With_Slash_Or_End_Without_Slash=\u8DEF\u5F91\u958B\u982D\u4E0D\u80FD\u52A0\u659C\u69D3\uFF0C\u5FC5\u9808\u4EE5\u659C\u69D3\u7D50\u5C3E
Plugin-S3_Access_Key_Id=AccessKeyId
Plugin-S3_Access_Key_Secret=AccessKeySecret
Plugin-S3_Bucket=Bucket
Plugin-S3_End_Point=Endpoint
Plugin-S3_Input=\u8ACB\u8F38\u5165
Plugin-S3_Region=Region
Plugin-S3_Other_Config=
Plugin-S3_EnablePathStyleAccess_Error_Tip=

192
src/main/resources/com/fanruan/fs/s3/repository/web/js/bundle.js

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save