Compare commits

..

84 Commits

Author SHA1 Message Date
Seth.Tian-田新兴 169ffa51e2 Pull request #402: JSY-31940 fix:修改分片上传 2 years ago
seth.tian 139ade57a9 JSY-31940 update:修改下版本号 2 years ago
seth.tian f8e1e9e277 JSY-31940 fix:修改分片上传 2 years ago
Seth.Tian-田新兴 6555c26f52 Pull request #203: JSY-29167 && JSY-28635 2 years ago
seth.tian 710182a7be JSY-29167 update:误提了一行 2 years ago
seth.tian 6a96e87ac6 JSY-29167 fix:文件删除 2 years ago
seth.tian 50e2a0cdf7 JSY-28635 fix:导出超过2G的文件写s3会异常,临时处理一下 2 years ago
Seth.Tian-田新兴 bf0912b2e4 Pull request #81: JSY-18781 fix:读写使用2个客户端,试试能否对性能有优化 2 years ago
seth.tian b02ffd616f JSY-18781 fix:修改版本号 2 years ago
seth.tian 4ea6de4a58 Merge remote-tracking branch 'origin/persist/jsy-11.0' into persist/jsy-11.0 2 years ago
seth.tian fe28d8a48c JSY-18781 fix:读写使用2个客户端,试试能否对性能有优化 2 years ago
Seth.Tian-田新兴 9513fd66f9 Pull request #80: JSY-23574 fix:插件修改新增加的配置后,显示不对 2 years ago
seth.tian 4f380943bd JSY-23574 fix:插件修改新增加的配置后,显示不对 2 years ago
Seth.Tian 8e2c9c319d Pull request #73: JSY-21884 update:开放useGzip, keepalive, maxConnection为系统配置 2 years ago
seth.tian 5c27ef1ce0 JSY-21884 update:开放useGzip, keepalive, maxConnection为系统配置 2 years ago
Icey.Zhang f3b8700e52 Pull request #71: 11.0.7-0803迭代版本插件代码合并 3 years ago
Icey.Zhang 3c088feaad Pull request #68: REPORT-76271 忘记更新插件版本号信息了,补一下插件的版本号信息 3 years ago
Ocean c25ba7c870 Merge remote-tracking branch 'origin/release/11.0' into release/11.0 3 years ago
Ocean 2bfac99c98 REPORT-76271 忘记更新插件版本号信息了,补一下插件的版本号信息 3 years ago
Ocean.Hu 4f1873fbfc Pull request #67: REPORT-76271 修复智能运维->集群配置界面,S3文件仓库无法使用http连接的问题 3 years ago
Ocean 2d554e9a25 REPORT-76271 修复智能运维->集群配置界面,S3文件仓库无法使用http连接的问题 3 years ago
Icey.Zhang de64b3a6cf Pull request #63: 11.0.6.1-0715维护版本插件代码合并 3 years ago
Afly 77ee1d9227 Pull request #61: REPORT-74814 feat: 新增两个后台配置项 3 years ago
Afly a3901cd06e REPORT-74814 feat: 新增两个后台配置项 3 years ago
Icey.Zhang a4b800248b Pull request #57: 11.0.6-0630迭代版本插件代码合并 3 years ago
Afly 6563376e98 Pull request #54: REPORT-72615 feat: 下个版本再内置,先回退 3 years ago
Afly c98a45e637 Merge branch 'release/11.0' of ssh://code.fineres.com:7999/~afly/plugin-repository-s3 into release/11.0 3 years ago
Afly 9580221e24 REPORT-72615 feat: 下个版本再内置,先回退 3 years ago
Afly 1dd2dcbe67 Pull request #52: REPORT-73356 && REPORT-72615 fix: 第三方组件升级,插件默认自动安装 3 years ago
Afly 0516aa2837 REPORT-73356 && REPORT-72615 fix: 第三方组件升级,插件默认自动安装 3 years ago
Icey.Zhang ecfe0eec98 Pull request #40: 11.0.3.1-0328维护版本插件代码合并 3 years ago
Afly 96077f1bbf Pull request #39: REPORT-67291 fix: 第三方组件升级 3 years ago
Afly ecd2da9775 REPORT-67291 fix: 第三方组件升级 3 years ago
Icey.Zhang 3ace1f233f Pull request #37: 11.0.2-0110迭代版本插件代码合并 3 years ago
lidongy 51c5478b2d Pull request #36: REPORT-64272 fix: fr-plugin-s3-repository插件中url更改 3 years ago
lidongy b8c38aaa18 Merge branch 'release/11.0' of https://code.fineres.com/scm/~lidongy/plugin-repository-s3 into release/11.0 3 years ago
lidongy 7b3ee6b47a REPORT-64272 fix: fr-plugin-s3-repository插件中url更改 3 years ago
lidongy d7c7630d03 Pull request #35: DEC-20707 chore: 提一下版本号 3 years ago
lidongy 4c5cb1a7d6 DEC-20707 chore: 提一下版本号 3 years ago
Icey.Zhang 102dc533e4 Pull request #34: 11.0-发布版本-1027版本插件代码合并 3 years ago
lidongy 6d75e6924c Pull request #33: 无jira任务 chore: 要发布了,修改change-note 3 years ago
lidongy 0bb59dd318 无jira任务 chore: 要发布了,修改change-note 3 years ago
lidongy 2537e05725 Pull request #31: DEC-20707 fix: s3直接通过判断名称 + "/"是否存在,来判断是否为文件夹 3 years ago
lidongy 0e76c422b6 DEC-20707 fix: s3直接通过判断名称 + "/"是否存在,来判断是否为文件夹 3 years ago
Dylan.Liu 2c042df4bd Pull request #26: init release/11.0 3 years ago
Dylan.Liu b84845ee29 init release/11.0 3 years ago
ju|剧浩宇 19dc9ba92e Pull request #24: INO-9768 跑FR 10.0.18国际化脚本+插件脚本 4 years ago
Joe.Jiang 8911690304 INO-9768 跑FR 10.0.18国际化脚本+插件脚本 4 years ago
Roger.Chen 41d0c61f78 Pull request #23: DEC-19779 fix: 添加一下国际化文件给国际组翻译 4 years ago
Roger.Chen 533df83872 DEC-19775 fix: 添加一下国际化文件给国际组翻译 4 years ago
Feng b6d9f00336 Pull request #21: DEC-18310 fix:文件服务器插件接口未兼容 4 years ago
Feng 4623bd97c8 DEC-18310 fix:文件服务器插件接口未兼容 4 years ago
Feng 8834f03f2b Pull request #20: QFX-5554 fix: 【冒烟】测试环境大数据量excel上传后点击保存无法保存成功 4 years ago
Feng cc8efcd603 QFX-5554 fix: 【冒烟】测试环境大数据量excel上传后点击保存无法保存成功 4 years ago
Feng 39b51beaf8 QFX-5554 fix: 【冒烟】测试环境大数据量excel上传后点击保存无法保存成功 4 years ago
Feng 3ddfba09e2 Pull request #17: 无jira 限制插件jartime 4 years ago
Feng 222b8c93e2 无jira 限制插件jartime 4 years ago
Frank.Qiu f5146deee0 Pull request #16: DEC-17106 fix: 【迭代】【S3插件】前端协议框与配置项框没有对齐 4 years ago
Frank.Qiu afbeeb7da0 DEC-17106 fix: 【迭代】【S3插件】前端协议框与配置项框没有对齐 4 years ago
Feng 7d2a958e8a Pull request #15: DEC-17012 fix: 【S3插件】备份文件删除后,实际文件服务器上文件未删除 4 years ago
Feng 3c1eb94de7 Merge remote-tracking branch 'origin/release/10.0' into release/10.0 4 years ago
Feng 4a0f1369d1 DEC-17012 fix: 【S3插件】备份文件删除后,实际文件服务器上文件未删除 4 years ago
Feng a56cdef22c Pull request #14: DEC-17013 fix: 【S3插件】备份模板很慢,有生成多余文件,后台很多警告 4 years ago
Feng 41d31de6e6 DEC-16997 fix: 【S3插件】定时调度的结果文件预览失败 4 years ago
Feng 9395670690 Merge remote-tracking branch 'origin/release/10.0' into release/10.0 4 years ago
Feng 893bbae5b4 DEC-17013 fix: 【S3插件】备份模板很慢,有生成多余文件,后台很多警告 4 years ago
Dylan.Liu 06689bd208 Pull request #12: DEC-16834 feat: 集群组件出错优化 4 years ago
Dylan.Liu 0402aa3a9e Merge branch 'release/10.0' of https://code.fineres.com/scm/~dylan.liu/plugin-repository-s3 into release/10.0 4 years ago
Dylan.Liu ac8ee784fe DEC-16834 feat: 集群组件出错优化 4 years ago
Feng 0506f22a5d Pull request #11: DEC-16997 fix: 【S3插件】定时调度的结果文件预览失败 4 years ago
Feng b3beded0f2 Merge remote-tracking branch 'origin/release/10.0' into release/10.0 4 years ago
Feng f16a557bf0 DEC-16997 fix: 【S3插件】定时调度的结果文件预览失败 4 years ago
Feng 2c5773904b DEC-16997 fix: 【S3插件】定时调度的结果文件预览失败 4 years ago
Feng 19a499536b Pull request #10: DEC-17006 fix: 【S3插件】配置输入不存在的路径也可以连接成功 4 years ago
Feng 39e97de37f DEC-17006 fix: 【S3插件】配置输入不存在的路径也可以连接成功 4 years ago
Feng d797433f1a Pull request #9: DEC-16411 feat: S3插件变为官方插件 国际化 4 years ago
Feng 1c342df1e0 DEC-16411 feat: S3插件变为官方插件 国际化 4 years ago
Feng 5724103649 DEC-16411 feat: S3插件变为官方插件 4 years ago
Feng dee24ab76e Pull request #8: DEC-16411 feat: S3插件变为官方插件 4 years ago
Feng 4bf15d218c DEC-16411 feat: S3插件变为官方插件 4 years ago
Feng b0a6e35c7c DEC-16411 feat: S3插件变为官方插件 4 years ago
Feng bba598df12 Pull request #6: DEC-16411 feat: S3插件作为官方插件维护 4 years ago
Feng ad2da13ab2 DEC-16411 S3仓库打包脚本 4 years ago
Feng ab60e1c61f DEC-16411 S3插件维护 4 years ago
  1. 6
      build.gradle
  2. 123
      build.xml
  3. BIN
      lib/httpclient-4.5.13.jar
  4. BIN
      lib/jackson-annotations-2.13.3.jar
  5. BIN
      lib/jackson-annotations-2.6.0.jar
  6. BIN
      lib/jackson-core-2.13.3.jar
  7. BIN
      lib/jackson-core-2.6.7.jar
  8. BIN
      lib/jackson-databind-2.13.3.jar
  9. BIN
      lib/jackson-databind-2.6.7.3.jar
  10. BIN
      lib/jackson-dataformat-cbor-2.13.3.jar
  11. BIN
      lib/jackson-dataformat-cbor-2.6.7.jar
  12. 22
      plugin.xml
  13. 4
      src/main/java/com/fanruan/fs/s3/repository/S3FileServerResource.java
  14. 70
      src/main/java/com/fanruan/fs/s3/repository/core/S3Config.java
  15. 42
      src/main/java/com/fanruan/fs/s3/repository/core/S3RepositoryFactory.java
  16. 2
      src/main/java/com/fanruan/fs/s3/repository/core/S3RepositoryProfile.java
  17. 337
      src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java
  18. 4
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3.properties
  19. 10
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3_en_US.properties
  20. 10
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3_ja_JP.properties
  21. 10
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3_ko_KR.properties
  22. 9
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3_zh_CN.properties
  23. 10
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3_zh_TW.properties
  24. 173
      src/main/resources/com/fanruan/fs/s3/repository/web/js/bundle.js

6
build.gradle

@ -1,3 +1,4 @@
apply plugin: 'java'
@ -9,6 +10,8 @@ ext {
*/
libPath = "$projectDir/../webroot/WEB-INF/lib"
fineVersion = '11.0-jsy-20221012'
/**
* class进行加密保护
*/
@ -117,5 +120,8 @@ dependencies {
//使jar
implementation fileTree(dir: 'lib', include: ['**/*.jar'])
implementation fileTree(dir: libPath, include: ['**/*.jar'])
compileOnly('com.fanruan.hihidata:fine-core:' + fineVersion)
compileOnly('com.fanruan.hihidata:fine-cbb:' + fineVersion)
compileOnly('com.fanruan.hihidata:fine-decision:' + fineVersion)
}

123
build.xml

@ -0,0 +1,123 @@
<?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>

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

Binary file not shown.

BIN
lib/jackson-annotations-2.13.3.jar

Binary file not shown.

BIN
lib/jackson-annotations-2.6.0.jar

Binary file not shown.

BIN
lib/jackson-core-2.13.3.jar

Binary file not shown.

BIN
lib/jackson-core-2.6.7.jar

Binary file not shown.

BIN
lib/jackson-databind-2.13.3.jar

Binary file not shown.

BIN
lib/jackson-databind-2.6.7.3.jar

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

22
plugin.xml

@ -1,17 +1,29 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<plugin>
<id>com.fanruan.fs.s3.repository</id>
<id>com.fanruan.fs.s3.repository.v11</id>
<name><![CDATA[S3资源仓库]]></name>
<main-package>com.fanruan.fs</main-package>
<active>yes</active>
<hidden>no</hidden>
<version>2.2</version>
<env-version>10.0</env-version>
<jartime>2020-01-27</jartime>
<version>1.3.8</version>
<env-version>11.0~11.0</env-version>
<jartime>2021-08-30</jartime>
<vendor>richie</vendor>
<description><![CDATA[使用支持S3协议的云存储文件系统作为文件服务器。]]></description>
<change-notes><![CDATA[
[2021-01-11]重写copy实现。<br/>
[2023-08-07]修改分片上传方法<br/>
[2022-07-25]修复http无法连接,而https和缺省的时候正常<br/>
[2022-06-30]新增enablePathStyleAccess、signerOverride后台配置<br/>
[2022-06-13]第三方组件升级<br/>
[2022-03-10]第三方组件升级<br/>
[2021-12-29]插件引用的url更改<br/>
[2021-10-08]修复文件夹误判问题。<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/>
[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.MainComponent;
import com.fr.decision.web.CommonComponent;
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 MainComponent.KEY;
return CommonComponent.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,19 +21,25 @@ public class S3Config extends CommonRepoConfig {
}
@Identifier("endPoint")
private Conf<String> endPoint = Holders.simple(StringUtils.EMPTY);
private Conf<String> endPoint = HolderKit.simple(StringUtils.EMPTY);
@Identifier("region")
private Conf<String> region = Holders.simple(StringUtils.EMPTY);
private Conf<String> region = HolderKit.simple(StringUtils.EMPTY);
@Identifier("accessKeyId")
private Conf<String> accessKeyId = Holders.simple(StringUtils.EMPTY);
@Identifier("accessKeySecret")
private Conf<String> accessKeySecret = Holders.simple(StringUtils.EMPTY);
private Conf<String> accessKeyId = HolderKit.simple(StringUtils.EMPTY);
@Identifier("bucket")
private Conf<String> bucket = Holders.simple(StringUtils.EMPTY);
private Conf<String> bucket = HolderKit.simple(StringUtils.EMPTY);
@Identifier("keepAlive")
private Conf<Boolean> keepAlive = HolderKit.simple(false);
@Identifier("useGzip")
private Conf<Boolean> useGzip = HolderKit.simple(false);
@Identifier("maxConnection")
private Conf<Integer> maxConnection = HolderKit.simple(50);
@GetConfig("endPoint")
public String getEndPoint() {
@ -65,16 +71,6 @@ 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();
@ -85,6 +81,36 @@ public class S3Config extends CommonRepoConfig {
this.bucket.set(bucket);
}
@GetConfig("keepAlive")
public boolean getKeepAlive() {
return this.keepAlive.get();
}
@SetConfig("keepAlive")
public void setKeepAlive(boolean keepAlive) {
this.keepAlive.set(keepAlive);
}
@GetConfig("useGzip")
public boolean getUseGzip() {
return useGzip.get();
}
@SetConfig("useGzip")
public void setUseGzip(boolean useGzip) {
this.useGzip.set(useGzip);
}
@GetConfig("maxConnection")
public int getMaxConnection() {
return maxConnection.get();
}
@SetConfig("maxConnection")
public void setMaxConnection(int maxConnection) {
this.maxConnection.set(maxConnection);
}
@Override
public void update(String key) {
super.update(key);
@ -93,8 +119,10 @@ 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.setKeepAlive(newConfig.getKeepAlive());
this.setUseGzip(newConfig.getUseGzip());
this.setMaxConnection(newConfig.getMaxConnection());
}
}
@ -104,8 +132,10 @@ 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.useGzip = (Conf<Boolean>) useGzip.clone();
cloned.keepAlive = (Conf<Boolean>) keepAlive.clone();
cloned.maxConnection = (Conf<Integer>) maxConnection.clone();
return cloned;
}
}

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

@ -1,19 +1,17 @@
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.AssistUtils;
import java.io.IOException;
import com.fr.stable.StringUtils;
/**
* @author richie
@ -23,8 +21,6 @@ import java.io.IOException;
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);
@ -43,39 +39,23 @@ public class S3RepositoryFactory extends ConfigRepositoryFactory<S3Config> {
@Override
public boolean verifyConfig(S3Config config) {
try {
BasicAWSCredentials credentials = new BasicAWSCredentials(config.getAccessKeyId(), config.getAccessKeySecret());
AmazonS3 s3 = AmazonS3ClientBuilder.standard()
BasicAWSCredentials credentials = new BasicAWSCredentials(config.getAccessKeyId(), config.getPassword());
AmazonS3ClientBuilder amazonS3ClientBuilder = AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(config.getEndPoint(), config.getRegion()))
.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);
}
.withCredentials(new AWSStaticCredentialsProvider(credentials));
ClientConfiguration clientConfiguration = new ClientConfiguration();
amazonS3ClientBuilder = amazonS3ClientBuilder.withClientConfiguration(clientConfiguration);
AmazonS3 s3 = amazonS3ClientBuilder.build();
s3.listObjects(config.getBucket());
} catch (Exception e) {
LogKit.error(e.getMessage(), e);
return false;
}
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();
}
}

2
src/main/java/com/fanruan/fs/s3/repository/core/S3RepositoryProfile.java

@ -30,8 +30,6 @@ public class S3RepositoryProfile extends RepositoryProfile<S3Config> {
this.s3Config.set(s3Config);
}
@Override
public RepositoryProfile<S3Config> clone() throws CloneNotSupportedException {
S3RepositoryProfile cloned = (S3RepositoryProfile) super.clone();

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

@ -1,28 +1,30 @@
package com.fanruan.fs.s3.repository.core;
import com.amazonaws.ClientConfiguration;
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.CopyObjectRequest;
import com.amazonaws.services.s3.model.DeleteObjectRequest;
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest;
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.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.stable.ArrayUtils;
import com.fr.stable.AssistUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Filter;
import com.fr.stable.StableUtils;
import com.fr.workspace.resource.ResourceIOException;
import java.io.ByteArrayInputStream;
@ -40,42 +42,51 @@ import java.util.List;
public class S3ResourceRepository extends BaseResourceRepository {
private static final String DELIMITER = "/";
private static final String CHAR_SET = "UTF-8";
/**
* 1G
*/
private static final int LENGTH_LIMIT = 1024 * 1024 * 1024;
/**
* 10M一个分片大小
*/
private static final int PART_SIZE = 10 * 1024 * 1024;
private final AmazonS3 s3;
private final AmazonS3 readClient;
private final AmazonS3 writeClient;
private final String bucket;
public S3ResourceRepository(String repoName, String workRoot, S3Config config) {
super(repoName, workRoot);
BasicAWSCredentials credentials = new BasicAWSCredentials(config.getAccessKeyId(), config.getAccessKeySecret());
this.s3 = AmazonS3ClientBuilder.standard()
BasicAWSCredentials credentials = new BasicAWSCredentials(config.getAccessKeyId(), config.getPassword());
AmazonS3ClientBuilder amazonS3ClientBuilder = AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(config.getEndPoint(), config.getRegion()))
.withCredentials(new AWSStaticCredentialsProvider(credentials)).build();
.withCredentials(new AWSStaticCredentialsProvider(credentials)).disableChunkedEncoding();
ClientConfiguration clientConfiguration = new ClientConfiguration();
clientConfiguration.setUseGzip(config.getUseGzip());
clientConfiguration.setUseTcpKeepAlive(config.getKeepAlive());
clientConfiguration.setMaxConnections(config.getMaxConnection());
amazonS3ClientBuilder = amazonS3ClientBuilder.withClientConfiguration(clientConfiguration);
this.readClient = amazonS3ClientBuilder.build();
this.writeClient = amazonS3ClientBuilder.build();
this.bucket = config.getBucket();
}
@Override
public String getSeparator() {
return "/";
return DELIMITER;
}
@Override
public FineFileEntry getEntry(String path) {
GetObjectRequest request = new GetObjectRequest(bucket, path);
try {
S3Object s3Object = s3.getObject(request);
try {
return s3Object2FileEntry(s3Object, path);
} finally {
s3Object.close();
}
ObjectMetadata metadata = readClient.getObjectMetadata(bucket, path);
return s3Object2FileEntry(metadata, path);
} catch (Exception e) {
LogKit.info("{} not exist!", path);
}
FineLoggerFactory.getLogger().error(e, "{} not exist!", path);
return null;
}
}
@Override
public FineFileEntry[] listEntry(String dir) {
@ -83,9 +94,12 @@ public class S3ResourceRepository extends BaseResourceRepository {
if (!dir.endsWith(DELIMITER)) {
dir += DELIMITER;
}
ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucket)
ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(this.bucket)
.withPrefix(dir).withDelimiter(DELIMITER);
ObjectListing objectListing = s3.listObjects(listObjectsRequest);
String nextMarker = null;
ObjectListing objectListing;
do {
objectListing = this.readClient.listObjects(listObjectsRequest.withMarker(nextMarker));
for (S3ObjectSummary summary : objectListing.getObjectSummaries()) {
String key = summary.getKey();
if (!key.endsWith(DELIMITER)) {
@ -98,54 +112,11 @@ public class S3ResourceRepository extends BaseResourceRepository {
result.add(entry);
}
nextMarker = objectListing.getNextMarker();
} while (objectListing.isTruncated());
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
public URL getResource(String path) {
throw new RuntimeException("Not support method.");
@ -155,8 +126,9 @@ public class S3ResourceRepository extends BaseResourceRepository {
public InputStream read(String filePath) throws ResourceIOException {
GetObjectRequest request = new GetObjectRequest(bucket, filePath);
try {
return s3.getObject(request).getObjectContent();
return readClient.getObject(request).getObjectContent();
} catch (Exception e) {
FineLoggerFactory.getLogger().warn(e, "[S3] read path {} is error!", filePath);
return new ByteArrayInputStream(new byte[0]);
}
}
@ -165,60 +137,144 @@ public class S3ResourceRepository extends BaseResourceRepository {
public void write(String path, byte[] data) {
ObjectMetadata metadata;
try {
metadata = s3.getObjectMetadata(bucket, path);
metadata = this.readClient.getObjectMetadata(this.bucket, path);
} catch (Exception e) {
FineLoggerFactory.getLogger().warn("[S3] getObjectMetaData error ,path {}", path);
metadata = new ObjectMetadata();
String mimeType = URLConnection.guessContentTypeFromName(path);
if (mimeType != null) {
metadata.setContentType(mimeType);
}
metadata.setContentLength(data.length);
}
if (metadata != null) {
metadata.setContentLength(data.length);
}
s3.putObject(bucket, path, new ByteArrayInputStream(data), metadata);
writeClient.putObject(bucket, path, new ByteArrayInputStream(data), metadata);
}
@Override
public void write(String path, InputStream inputStream) throws ResourceIOException {
if (null == inputStream) {
this.writeClient.putObject(this.bucket, path, "");
} else {
ObjectMetadata metadata = new ObjectMetadata();
try {
// 大于1.5G的,就自己算一下长度
if (inputStream.available() > LENGTH_LIMIT) {
List<PartETag> partETags = new ArrayList<>();
InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest(bucket, path);
InitiateMultipartUploadResult initResponse = this.writeClient.initiateMultipartUpload(initRequest);
final String uploadId = initResponse.getUploadId();
byte[] buffer = new byte[PART_SIZE];
int bytesRead;
int partNumber = 1;
while ((bytesRead = inputStream.read(buffer)) > 0) {
// Create the request to upload a part.
UploadPartRequest uploadRequest = new UploadPartRequest()
.withBucketName(bucket)
.withKey(path)
.withUploadId(uploadId)
.withPartNumber(partNumber)
.withInputStream(new ByteArrayInputStream(buffer, 0, bytesRead))
.withPartSize(bytesRead);
final UploadPartResult uploadPartResult = this.writeClient.uploadPart(uploadRequest);
partETags.add(uploadPartResult.getPartETag());
partNumber++;
}
CompleteMultipartUploadRequest compRequest = new CompleteMultipartUploadRequest(bucket, path,
initResponse.getUploadId(), partETags);
this.writeClient.completeMultipartUpload(compRequest);
} else {
metadata.setContentLength(inputStream.available());
this.writeClient.putObject(this.bucket, path, inputStream, metadata);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().info("S3 inputStream.putObject error,path is {}, error message {}", path, e.getMessage());
} finally {
try {
inputStream.close();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, "[S3] error,path is {}, error message {}", path, e.getMessage());
}
}
}
}
@Override
public boolean createFile(String path) {
PutObjectRequest request = new PutObjectRequest(bucket, path, new ByteArrayInputStream(new byte[0]), new ObjectMetadata());
List<String> paths = getAllNecessaryPath(path);
for (int i = paths.size() - 1; i >= 0; i--) {
String parent = paths.get(i);
PutObjectRequest req = new PutObjectRequest(this.bucket, parent, new ByteArrayInputStream(new byte[0]), buildEmptyMetadata());
try {
s3.putObject(request);
this.writeClient.putObject(req);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, "[S3] Failed to create parent path {}", parent);
return false;
}
}
return true;
}
@Override
public boolean createDirectory(String path) {
PutObjectRequest request = new PutObjectRequest(bucket, path + "/", new ByteArrayInputStream(new byte[0]), new ObjectMetadata());
if (!path.endsWith(DELIMITER)) {
path += DELIMITER;
}
List<String> paths = getAllNecessaryPath(path);
for (int i = paths.size() - 1; i >= 0; i--) {
String parent = paths.get(i);
PutObjectRequest req = new PutObjectRequest(bucket, parent, new ByteArrayInputStream(new byte[0]), buildEmptyMetadata());
try {
s3.putObject(request);
writeClient.putObject(req);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, "[S3] Failed to create parent path {}", parent);
return false;
}
}
return true;
}
@Override
public boolean delete(String path) {
this.writeClient.deleteObject(this.bucket, path);
String prefix = path;
if (!path.endsWith(DELIMITER)) {
prefix = path + DELIMITER;
}
try {
s3.deleteObject(bucket, path);
ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(this.bucket)
.withPrefix(prefix).withDelimiter(DELIMITER);
ObjectListing objectListing;
String nextMarker = null;
do {
objectListing = this.readClient.listObjects(listObjectsRequest.withMarker(nextMarker));
for (S3ObjectSummary summary : objectListing.getObjectSummaries()) {
String key = summary.getKey();
if (!key.endsWith(DELIMITER)) {
this.writeClient.deleteObject(this.bucket, key);
}
}
for (String pre : objectListing.getCommonPrefixes()) {
delete(pre);
}
nextMarker = objectListing.getNextMarker();
} while (objectListing.isTruncated());
} catch (Exception e) {
LogKit.error(e.getMessage(), e);
return false;
FineLoggerFactory.getLogger().error(e, "[S3] delete error path {}", path);
}
this.writeClient.deleteObject(this.bucket, prefix);
return true;
}
@Override
public boolean exist(String path) {
try {
return s3.doesObjectExist(bucket, path);
return this.readClient.doesObjectExist(this.bucket, path) || this.readClient.doesObjectExist(this.bucket, path + DELIMITER);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, "[S3] exist error path {}", path);
return false;
}
}
@ -229,11 +285,18 @@ public class S3ResourceRepository extends BaseResourceRepository {
if (!dir.endsWith(DELIMITER)) {
dir += DELIMITER;
}
ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucket)
ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(this.bucket)
.withPrefix(dir).withDelimiter(DELIMITER);
ObjectListing objectListing = s3.listObjects(listObjectsRequest);
String nextMarker = null;
ObjectListing objectListing;
do {
objectListing = this.readClient.listObjects(listObjectsRequest.withMarker(nextMarker));
for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) {
String[] arr = objectSummary.getKey().split(DELIMITER);
String key = objectSummary.getKey();
if (StringKit.equals(key, dir)) {
continue;
}
String[] arr = key.split(DELIMITER);
String name = arr[arr.length - 1];
if (filter == null) {
result.add(name);
@ -254,30 +317,20 @@ public class S3ResourceRepository extends BaseResourceRepository {
}
}
}
nextMarker = objectListing.getNextMarker();
} while (objectListing.isTruncated());
return result.toArray(new String[0]);
}
@Override
public boolean isDirectory(String path) {
if (path.endsWith(DELIMITER)) {
return true;
}
ObjectListing listing = s3.listObjects(bucket, path);
if (listing.getObjectSummaries().isEmpty()) {
return false;
}
if (listing.getObjectSummaries().size() > 1) {
return true;
} else {
S3ObjectSummary summary = listing.getObjectSummaries().get(0);
return !StringKit.equals(listing.getPrefix(), summary.getKey());
}
return exist(path.endsWith(DELIMITER) ? path : path + DELIMITER);
}
@Override
public long lastModified(String path) {
try {
S3Object s3Object = s3.getObject(bucket, path);
S3Object s3Object = this.readClient.getObject(this.bucket, path);
if (s3Object != null) {
try {
return s3Object.getObjectMetadata().getLastModified().getTime();
@ -286,25 +339,18 @@ public class S3ResourceRepository extends BaseResourceRepository {
}
}
} catch (Exception e) {
LogKit.info("{} not exist!", path);
FineLoggerFactory.getLogger().error(e, "[S3] {} not exist!", path);
}
return -1L;
}
@Override
public long length(String path) {
try {
S3Object s3Object = s3.getObject(bucket, path);
if (s3Object != null) {
try {
return s3Object.getObjectMetadata().getContentLength();
} finally {
s3Object.close();
}
}
ObjectMetadata metadata = this.readClient.getObjectMetadata(this.bucket, path);
return metadata.getContentLength();
} catch (Exception e) {
LogKit.info("{} not exist!", path);
LogKit.info("[S3] {} not exist!", path);
}
return -1L;
@ -312,21 +358,27 @@ public class S3ResourceRepository extends BaseResourceRepository {
@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;
if (copy(path, newPath) && delete(path)) {
if (FineLoggerFactory.getLogger().isDebugEnabled()) {
FineLoggerFactory.getLogger().debug("[S3] rename {} to {} success.", path, newPath);
}
return true;
} else {
FineLoggerFactory.getLogger().error("[S3] rename {} to {} failed.", path, newPath);
return false;
}
}
@Override
public boolean copyFile(String origPath, String desPath) throws ResourceIOException {
writeClient.copyObject(bucket, origPath, bucket, desPath);
return exist(desPath);
}
@Override
public void shutDown() {
s3.shutdown();
readClient.shutdown();
writeClient.shutdown();
}
@Override
@ -334,4 +386,53 @@ 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;
}
/**
* 递归创建父目录的metadata. 比如path是 {@code WEB-INF/reportlets/test/1.cpt}
* 则返回 {@code [WEB-INF/reportlets/test/1.cpt, WEB-INF/reportlets/test/, WEB-INF/reportlets/, WEB-INF/]}
*/
private List<String> getAllNecessaryPath(String path) {
// 获取所有path路径及其所有父路径
List<String> allPath = new ArrayList<>();
allPath.add(path);
int lastIdxOfDelimiter = path.lastIndexOf(DELIMITER);
// 以/结尾的先把末尾的/去掉
if (lastIdxOfDelimiter == path.length() - 1) {
path = path.substring(0, lastIdxOfDelimiter);
lastIdxOfDelimiter = path.lastIndexOf(DELIMITER);
}
while (lastIdxOfDelimiter > 0) {
allPath.add(path.substring(0, lastIdxOfDelimiter + 1));
path = path.substring(0, lastIdxOfDelimiter);
lastIdxOfDelimiter = path.lastIndexOf(DELIMITER);
}
return allPath;
}
}

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

@ -4,3 +4,7 @@ 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_Keep_Alive=keepAlive
Plugin-S3_Use_Gzip=useGzip
Plugin-S3_Max_Connection=maxConnection

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

@ -1,6 +1,10 @@
Plugin-S3_Input=Please Input
Plugin-S3_End_Point=Endpoint
Plugin-S3_Region=Region
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_End_Point=Endpoint
Plugin-S3_Input=Please input
Plugin-S3_Region=Region
Plugin-S3_Keep_Alive=keepAlive
Plugin-S3_Use_Gzip=useGzip
Plugin-S3_Max_Connection=maxConnection

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

@ -0,0 +1,10 @@
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_Keep_Alive=keepAlive
Plugin-S3_Use_Gzip=useGzip
Plugin-S3_Max_Connection=maxConnection

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

@ -0,0 +1,10 @@
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_Keep_Alive=keepAlive
Plugin-S3_Use_Gzip=useGzip
Plugin-S3_Max_Connection=maxConnection

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

@ -1,6 +1,9 @@
Plugin-S3_Input=\u8BF7\u8F93\u5165
Plugin-S3_End_Point=Endpoint
Plugin-S3_Region=Region
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_Keep_Alive=keepAlive
Plugin-S3_Use_Gzip=useGzip
Plugin-S3_Max_Connection=maxConnection

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

@ -0,0 +1,10 @@
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_Keep_Alive=keepAlive
Plugin-S3_Use_Gzip=useGzip
Plugin-S3_Max_Connection=maxConnection

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

@ -3,24 +3,26 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
value: "S3", // 地址栏显示的hash值
id: "decision-intelligence-cluster-file-s3", // id
text: "S3", // 文字
cardType: "dec.intelligence.cluster.file.s3"
cardType: "dec.intelligence.cluster.file.s3",
workRoot: false,
});
return items;
});
!(function () {
var LABEL_WIDTH = 116, EDITOR_WIDTH = 300;
var LABEL_WIDTH = 107, EDITOR_WIDTH = 393;
var S3 = BI.inherit(BI.Widget, {
props: {
baseCls: "dec-cluster-ftp",
value: {}
value: {},
},
_store: function () {
return BI.Models.getModel("dec.model.intelligence.cluster.file.s3", {
value: this.options.value
value: this.options.value,
});
},
@ -28,6 +30,7 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
render: function () {
var self = this, o = this.options;
return {
type: "bi.vertical",
tgap: 15,
@ -49,8 +52,8 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
eventName: BI.Editor.EVENT_CHANGE,
action: function () {
self.store.setEndPoint(this.getValue());
}
}]
},
}],
}, {
type: "dec.label.editor.item",
textWidth: LABEL_WIDTH,
@ -68,8 +71,8 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
eventName: BI.Editor.EVENT_CHANGE,
action: function () {
self.store.setRegion(this.getValue());
}
}]
},
}],
}, {
type: "dec.label.editor.item",
textWidth: LABEL_WIDTH,
@ -87,25 +90,22 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
eventName: BI.Editor.EVENT_CHANGE,
action: function () {
self.store.setAccessKeyId(this.getValue());
}
}]
},
}],
},
{
type: "dec.label.editor.item",
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: "******",
value: this.model.password,
el: {
disabled: !o.editable,
disabled: !o.editable
},
ref: function (_ref) {
self.passwordRow = _ref;
},
listeners: [{
eventName: BI.Editor.EVENT_CHANGE,
action: function () {
self.store.setAccessKeySecret(this.getValue());
}
}]
},
{
type: "dec.label.editor.item",
@ -115,15 +115,84 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
text: BI.i18nText("Plugin-S3_Bucket"),
value: this.model.bucket,
el: {
disabled: !o.editable,
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: "dec.label.editor.item",
textWidth: LABEL_WIDTH,
editorWidth: EDITOR_WIDTH,
watermark: BI.i18nText("Plugin-S3_Input"),
text: "keepAlive",
value: this.model.keepAlive,
el: {
disabled: !o.editable,
type: "bi.switch",
selected: this.model.keepAlive,
listeners: [{
eventName: BI.Editor.EVENT_CHANGE,
action: function () {
self.store.setKeepAlive(this.isSelected());
},
}],
},
},{
type: "dec.label.editor.item",
textWidth: LABEL_WIDTH,
editorWidth: EDITOR_WIDTH,
watermark: BI.i18nText("Plugin-S3_Input"),
text: "useGzip",
value: this.model.useGzip,
el: {
disabled: !o.editable,
type: "bi.switch",
selected: this.model.useGzip,
listeners: [
{
eventName: BI.Switcher.EVENT_CHANGE,
action: function () {
self.store.setUseGzip(this.isSelected());
},
},
],
},
},{
type: "dec.label.editor.item",
textWidth: LABEL_WIDTH,
editorWidth: EDITOR_WIDTH,
watermark: BI.i18nText("Plugin-S3_Input"),
text: "maxConnection",
value: this.model.maxConnection,
el: {
disabled: !o.editable,
listeners: [{
eventName: BI.Editor.EVENT_CHANGE,
action: function () {
self.store.setMaxConnection(this.getValue());
},
}],
},
}],
};
},
@ -132,14 +201,37 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
endPoint: this.model.endPoint,
region: this.model.region,
accessKeyId: this.model.accessKeyId,
accessKeySecret: this.model.accessKeySecret,
bucket: this.model.bucket
password: this.passwordRow.getCipher(),
bucket: this.model.bucket,
keepAlive: this.model.keepAlive,
useGzip: this.model.useGzip,
maxConnection: this.model.maxConnection,
workRoot: this.filePathRow.getValue(),
};
},
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;
}
return valid;
},
});
BI.shortcut("dec.intelligence.cluster.file.s3", S3);
})();
}());
!(function () {
@ -147,12 +239,17 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
state: function () {
var val = this.options.value;
return {
endPoint: val.endPoint,
region: val.region,
accessKeyId: val.accessKeyId,
accessKeySecret: val.accessKeySecret,
bucket: val.bucket
password: val.password,
bucket: val.bucket,
workRoot: val.workRoot,
keepAlive: val.keepAlive,
useGzip: val.useGzip,
maxConnection: val.maxConnection||50,
};
},
@ -160,10 +257,10 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
encodingArray: function () {
return BI.map(DecCst.EncodeConstants.ENCODING_ARRAY, function (i, v) {
return {
value: v
value: v,
};
});
}
},
},
actions: {
@ -179,13 +276,19 @@ BI.config("dec.constant.intelligence.cluster.file.server", function (items) {
this.model.accessKeyId = v;
},
setAccessKeySecret: function (v) {
this.model.accessKeySecret = v;
},
setBucket: function (v) {
this.model.bucket = v;
},
setKeepAlive: function (v){
this.model.keepAlive = v;
},
setUseGzip: function (v){
this.model.useGzip = v;
},
setMaxConnection: function (v){
this.model.maxConnection = Number.parseInt(v);
}
}
},
});
BI.model("dec.model.intelligence.cluster.file.s3", Model);
})();
}());

Loading…
Cancel
Save