Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
0f8e8e5c
o2oa
项目概览
ghsby
/
o2oa
落后 Fork 源项目 2880 个版本
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0f8e8e5c
编写于
6月 10, 2022
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
附件上传sftp模式支持指定根目录(原先上传到用户目录下)
上级
c08a2429
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
40 deletion
+29
-40
o2server/x_base_core_project/src/main/java/com/x/base/core/entity/StorageObject.java
...t/src/main/java/com/x/base/core/entity/StorageObject.java
+29
-40
未找到文件。
o2server/x_base_core_project/src/main/java/com/x/base/core/entity/StorageObject.java
浏览文件 @
0f8e8e5c
package
com.x.base.core.entity
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.FileNotFoundException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.util.Date
;
import
java.util.Objects
;
import
javax.persistence.MappedSuperclass
;
import
javax.persistence.Transient
;
import
com.x.base.core.project.config.StorageMapping
;
import
com.x.base.core.project.tools.DefaultCharset
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.vfs2.CacheStrategy
;
import
org.apache.commons.vfs2.FileObject
;
import
org.apache.commons.vfs2.FileSystemException
;
import
org.apache.commons.vfs2.FileSystemManager
;
import
org.apache.commons.vfs2.FileSystemOptions
;
import
org.apache.commons.vfs2.*
;
import
org.apache.commons.vfs2.cache.NullFilesCache
;
import
org.apache.commons.vfs2.impl.StandardFileSystemManager
;
import
org.apache.commons.vfs2.provider.ftp.FtpFileSystemConfigBuilder
;
import
org.apache.commons.vfs2.provider.ftp.FtpFileType
;
import
org.apache.commons.vfs2.provider.ftps.FtpsFileSystemConfigBuilder
;
import
org.apache.commons.vfs2.provider.sftp.SftpFileSystemConfigBuilder
;
import
org.apache.commons.vfs2.provider.webdav4.Webdav4FileSystemConfigBuilder
;
import
com.x.base.core.project.config.StorageMapping
;
import
com.x.base.core.project.tools.DefaultCharset
;
import
javax.persistence.MappedSuperclass
;
import
javax.persistence.Transient
;
import
java.io.FileNotFoundException
;
import
java.io.*
;
import
java.net.URLEncoder
;
import
java.time.Duration
;
import
java.util.Date
;
import
java.util.Objects
;
@MappedSuperclass
public
abstract
class
StorageObject
extends
SliceJpaObject
{
...
...
@@ -165,7 +157,7 @@ public abstract class StorageObject extends SliceJpaObject {
/**
* 读出内容
*
*
* @param mapping
* @return
* @throws Exception
...
...
@@ -179,7 +171,7 @@ public abstract class StorageObject extends SliceJpaObject {
/**
* 将内容流出到output
*
*
* @param mapping
* @param output
* @return
...
...
@@ -195,7 +187,7 @@ public abstract class StorageObject extends SliceJpaObject {
/**
* 检查是否存在内容
*
*
* @param mapping
* @return
* @throws Exception
...
...
@@ -218,7 +210,7 @@ public abstract class StorageObject extends SliceJpaObject {
/**
* 取得完整访问路径的前半部分
*
*
* @param mapping
* @return
* @throws IllegalStateException
...
...
@@ -290,16 +282,13 @@ public abstract class StorageObject extends SliceJpaObject {
}
switch
(
mapping
.
getProtocol
())
{
case
sftp:
FtpFileSystemConfigBuilder
sftpBuilder
=
FtpFileSystemConfigBuilder
.
getInstance
();
sftpBuilder
.
setPassiveMode
(
opts
,
true
);
// 强制不校验IP
sftpBuilder
.
setRemoteVerification
(
opts
,
false
);
sftpBuilder
.
setFileType
(
opts
,
FtpFileType
.
BINARY
);
sftpBuilder
.
setConnectTimeout
(
opts
,
10
*
1000
);
sftpBuilder
.
setSoTimeout
(
opts
,
10
*
1000
);
sftpBuilder
.
setControlEncoding
(
opts
,
DefaultCharset
.
name
);
SftpFileSystemConfigBuilder
sftpBuilder
=
SftpFileSystemConfigBuilder
.
getInstance
();
sftpBuilder
.
setConnectTimeout
(
opts
,
Duration
.
ofMillis
(
10
*
1000
));
sftpBuilder
.
setSessionTimeout
(
opts
,
Duration
.
ofMillis
(
30
*
1000
));
sftpBuilder
.
setFileNameEncoding
(
opts
,
DefaultCharset
.
name
);
// By default, the path is relative to the user's home directory. This can be
// changed with:
sftpBuilder
.
setStrictHostKeyChecking
(
opts
,
"no"
);
sftpBuilder
.
setUserDirIsRoot
(
opts
,
false
);
break
;
case
ftp:
...
...
@@ -320,8 +309,8 @@ public abstract class StorageObject extends SliceJpaObject {
ftpBuilder
.
setRemoteVerification
(
opts
,
false
);
// FtpFileType.BINARY is the default
ftpBuilder
.
setFileType
(
opts
,
FtpFileType
.
BINARY
);
ftpBuilder
.
setConnectTimeout
(
opts
,
10
*
1000
);
ftpBuilder
.
setSoTimeout
(
opts
,
10
*
1000
);
ftpBuilder
.
setConnectTimeout
(
opts
,
Duration
.
ofMillis
(
10
*
1000
)
);
ftpBuilder
.
setSoTimeout
(
opts
,
Duration
.
ofMillis
(
10
*
1000
)
);
ftpBuilder
.
setControlEncoding
(
opts
,
DefaultCharset
.
name
);
break
;
case
ftps:
...
...
@@ -331,16 +320,16 @@ public abstract class StorageObject extends SliceJpaObject {
ftpsBuilder
.
setRemoteVerification
(
opts
,
false
);
// FtpFileType.BINARY is the default
ftpsBuilder
.
setFileType
(
opts
,
FtpFileType
.
BINARY
);
ftpsBuilder
.
setConnectTimeout
(
opts
,
10
*
1000
);
ftpsBuilder
.
setSoTimeout
(
opts
,
10
*
1000
);
ftpsBuilder
.
setConnectTimeout
(
opts
,
Duration
.
ofMillis
(
10
*
1000
)
);
ftpsBuilder
.
setSoTimeout
(
opts
,
Duration
.
ofMillis
(
10
*
1000
)
);
ftpsBuilder
.
setControlEncoding
(
opts
,
DefaultCharset
.
name
);
break
;
case
cifs:
break
;
case
webdav:
Webdav4FileSystemConfigBuilder
webdavBuilder
=
Webdav4FileSystemConfigBuilder
.
getInstance
();
webdavBuilder
.
setConnectionTimeout
(
opts
,
10
*
1000
);
webdavBuilder
.
setSoTimeout
(
opts
,
10
*
1000
);
webdavBuilder
.
setConnectionTimeout
(
opts
,
Duration
.
ofMillis
(
10
*
1000
)
);
webdavBuilder
.
setSoTimeout
(
opts
,
Duration
.
ofMillis
(
10
*
1000
)
);
webdavBuilder
.
setUrlCharset
(
opts
,
DefaultCharset
.
name
);
webdavBuilder
.
setMaxConnectionsPerHost
(
opts
,
200
);
webdavBuilder
.
setMaxTotalConnections
(
opts
,
200
);
...
...
@@ -395,7 +384,7 @@ public abstract class StorageObject extends SliceJpaObject {
/**
* vfs读取数据
*
*
* @param mapping
* @param output
* @return
...
...
@@ -437,7 +426,7 @@ public abstract class StorageObject extends SliceJpaObject {
/**
* 删除内容,同时判断上一级目录(只判断一级)是否为空,为空则删除上一级目录
*
*
* @param mapping
* @throws Exception
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录