Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
E
EncryptedFileSystem
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhangshuang
EncryptedFileSystem
Commits
6cab523d
提交
6cab523d
authored
3月 26, 2020
作者:
zhangshuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
文件信息保存数据库与swagger
上级
00b27522
显示空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
54 行增加
和
53 行删除
+54
-53
ServerResponse.java
...n/java/com/zjty/efs/ftp/base/response/ServerResponse.java
+1
-1
FileUploadController.java
...ava/com/zjty/efs/ftp/controller/FileUploadController.java
+12
-7
CheckChunkRequest.java
.../main/java/com/zjty/efs/ftp/entity/CheckChunkRequest.java
+3
-3
CheckChunkResponse.java
...main/java/com/zjty/efs/ftp/entity/CheckChunkResponse.java
+4
-4
FileSave.java
efs-ftp/src/main/java/com/zjty/efs/ftp/entity/FileSave.java
+5
-5
MergeRequest.java
...p/src/main/java/com/zjty/efs/ftp/entity/MergeRequest.java
+4
-4
MergeResponse.java
.../src/main/java/com/zjty/efs/ftp/entity/MergeResponse.java
+4
-4
UploadRequest.java
.../src/main/java/com/zjty/efs/ftp/entity/UploadRequest.java
+4
-5
FileUploadService.java
...main/java/com/zjty/efs/ftp/service/FileUploadService.java
+1
-1
FileDownLoadServiceImpl.java
...om/zjty/efs/ftp/service/impl/FileDownLoadServiceImpl.java
+13
-9
FileUploadServiceImpl.java
.../com/zjty/efs/ftp/service/impl/FileUploadServiceImpl.java
+2
-9
application.properties
efs-union/src/main/resources/application.properties
+1
-1
没有找到文件。
efs-ftp/src/main/java/com/zjty/efs/ftp/base/response/ServerResponse.java
浏览文件 @
6cab523d
...
...
@@ -18,7 +18,7 @@ import static com.zjty.efs.ftp.base.response.ResponseCode.*;
@SuppressWarnings
({
"WeakerAccess"
,
"unused"
})
@Getter
@AutoDocument
@ApiModel
(
value
=
"
响应体
"
,
description
=
"封装好的响应体"
)
@ApiModel
(
value
=
"
ServerResponse
"
,
description
=
"封装好的响应体"
)
public
class
ServerResponse
<
T
>
{
/**
* 错误码
...
...
efs-ftp/src/main/java/com/zjty/efs/ftp/controller/FileUploadController.java
浏览文件 @
6cab523d
...
...
@@ -27,10 +27,10 @@ public class FileUploadController {
private
FileUploadService
fileUploadService
;
//文件上传
@PutMapping
(
"/upload"
)
/*
@PutMapping("/upload")
public ServerResponse fileUpload(HttpServletRequest httpServletRequest){
return fileUploadService.fileUpload(httpServletRequest);
}
}
*/
/* *//**
* @author zs
...
...
@@ -53,7 +53,7 @@ public class FileUploadController {
@PostMapping
(
"/checkChunk"
)
@ApiOperation
(
value
=
"分片检查"
,
notes
=
"检查分片存不存在"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"checkChunkRequests"
,
value
=
"检查分片集合存不存在"
,
paramType
=
"query"
,
required
=
true
)
@ApiImplicitParam
(
name
=
"checkChunkRequests"
,
value
=
"检查分片集合存不存在"
,
dataType
=
"List"
,
paramType
=
"query"
,
required
=
true
)
})
public
ServerResponse
checkChunk
(
@RequestBody
List
<
CheckChunkRequest
>
checkChunkRequests
)
{
return
fileUploadService
.
checkChunk
(
checkChunkRequests
);
...
...
@@ -66,10 +66,15 @@ public class FileUploadController {
@PostMapping
(
"/upload"
)
@ApiOperation
(
value
=
"文件上传"
,
notes
=
"上传文件,支持断点续传"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"uploadRequests"
,
value
=
"上传文件的集合"
,
paramType
=
"query"
,
required
=
true
)
@ApiImplicitParam
(
name
=
"file"
,
value
=
"文件"
,
dataType
=
"file"
,
paramType
=
"query"
,
required
=
true
),
@ApiImplicitParam
(
name
=
"md5File"
,
value
=
"MD5生成的文件名"
,
dataType
=
"String"
,
paramType
=
"query"
,
required
=
true
),
@ApiImplicitParam
(
name
=
"chunk"
,
value
=
"分片"
,
dataType
=
"String"
,
paramType
=
"query"
)
})
public
ServerResponse
upload
(
@RequestBody
List
<
UploadRequest
>
uploadRequests
)
{
//第几片,从0开始
return
fileUploadService
.
upload
(
uploadRequests
);
@ResponseBody
public
ServerResponse
upload
(
@RequestParam
(
value
=
"file"
)
MultipartFile
file
,
@RequestParam
(
value
=
"md5File"
)
String
md5File
,
@RequestParam
(
value
=
"chunk"
,
required
=
false
)
Integer
chunk
)
{
//第几片,从0开始
return
fileUploadService
.
upload
(
file
,
md5File
,
chunk
);
}
/**
...
...
@@ -79,7 +84,7 @@ public class FileUploadController {
@PostMapping
(
"/merge"
)
@ApiOperation
(
value
=
"合成分片"
,
notes
=
"合成所有分片"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"mergeRequests"
,
value
=
"需要分片合成的集合"
,
paramType
=
"query"
,
required
=
true
)
@ApiImplicitParam
(
name
=
"mergeRequests"
,
value
=
"需要分片合成的集合"
,
dataType
=
"list"
,
paramType
=
"query"
,
required
=
true
)
})
public
ServerResponse
merge
(
@RequestBody
List
<
MergeRequest
>
mergeRequests
){
return
fileUploadService
.
merge
(
mergeRequests
);
...
...
efs-ftp/src/main/java/com/zjty/efs/ftp/entity/CheckChunkRequest.java
浏览文件 @
6cab523d
...
...
@@ -11,11 +11,11 @@ import lombok.NoArgsConstructor;
@AutoDocument
@AllArgsConstructor
@NoArgsConstructor
@ApiModel
(
value
=
"
分片检查
"
,
description
=
"分片检查请求体"
)
@ApiModel
(
value
=
"
CheckChunkRequest
"
,
description
=
"分片检查请求体"
)
@Data
public
class
CheckChunkRequest
{
@ApiModelProperty
(
value
=
"md5File
"
,
notes
=
"md5生成的文件夹名称"
)
@ApiModelProperty
(
name
=
"md5File"
,
value
=
"md5生成的文件夹名称
"
,
notes
=
"md5生成的文件夹名称"
)
private
String
md5File
;
@ApiModelProperty
(
value
=
"chunk
"
,
notes
=
"当前分片"
)
@ApiModelProperty
(
name
=
"chunk"
,
value
=
"当前分片
"
,
notes
=
"当前分片"
)
private
Integer
chunk
;
}
efs-ftp/src/main/java/com/zjty/efs/ftp/entity/CheckChunkResponse.java
浏览文件 @
6cab523d
...
...
@@ -12,12 +12,12 @@ import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel
(
value
=
"
分片检查
"
,
description
=
"分片检查响应体"
)
@ApiModel
(
value
=
"
CheckChunkResponse
"
,
description
=
"分片检查响应体"
)
public
class
CheckChunkResponse
{
@ApiModelProperty
(
value
=
"md5File
"
,
notes
=
"md5生成的文件夹名称"
)
@ApiModelProperty
(
name
=
"md5File"
,
value
=
"md5生成的文件夹名称
"
,
notes
=
"md5生成的文件夹名称"
)
private
String
md5File
;
@ApiModelProperty
(
value
=
"chunk
"
,
notes
=
"当前分片"
)
@ApiModelProperty
(
name
=
"chunk"
,
value
=
"当前分片
"
,
notes
=
"当前分片"
)
private
Integer
chunk
;
@ApiModelProperty
(
value
=
"exist
"
,
notes
=
"是否存在 0-不存在 1-存在"
)
@ApiModelProperty
(
name
=
"exist"
,
value
=
"是否存在 0-不存在 1-存在
"
,
notes
=
"是否存在 0-不存在 1-存在"
)
private
Integer
exist
;
}
efs-ftp/src/main/java/com/zjty/efs/ftp/entity/FileSave.java
浏览文件 @
6cab523d
...
...
@@ -18,16 +18,16 @@ import javax.persistence.Id;
@NoArgsConstructor
@Data
@Entity
@ApiModel
(
value
=
"
文件存储
"
,
description
=
"将文件信息存储在数据库中"
)
@ApiModel
(
value
=
"
FileSave
"
,
description
=
"将文件信息存储在数据库中"
)
public
class
FileSave
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
@ApiModelProperty
(
value
=
"
id"
,
notes
=
"文件id"
,
example
=
"1"
)
@ApiModelProperty
(
name
=
"id"
,
value
=
"文件
id"
,
notes
=
"文件id"
,
example
=
"1"
)
private
Integer
id
;
//文件id
@ApiModelProperty
(
value
=
"realName
"
,
notes
=
"文件真正存储名称"
,
example
=
"1(1).zip"
)
@ApiModelProperty
(
name
=
"realName"
,
value
=
"文件真正存储名称
"
,
notes
=
"文件真正存储名称"
,
example
=
"1(1).zip"
)
private
String
realName
;
//真实名称
@ApiModelProperty
(
value
=
"fileName
"
,
notes
=
"文件传入名称"
,
example
=
"1.zip"
)
@ApiModelProperty
(
name
=
"fileName"
,
value
=
"文件传入名称
"
,
notes
=
"文件传入名称"
,
example
=
"1.zip"
)
private
String
fileName
;
//传入名称
@ApiModelProperty
(
value
=
"path
"
,
notes
=
"文件真正存储路径"
,
example
=
"/file/uploads/1(1).zip"
)
@ApiModelProperty
(
name
=
"path"
,
value
=
"文件真正存储路径
"
,
notes
=
"文件真正存储路径"
,
example
=
"/file/uploads/1(1).zip"
)
private
String
path
;
//文件存储路径
}
efs-ftp/src/main/java/com/zjty/efs/ftp/entity/MergeRequest.java
浏览文件 @
6cab523d
...
...
@@ -12,12 +12,12 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Data
@ApiModel
(
value
=
"
合并
"
,
description
=
"合并请求体"
)
@ApiModel
(
value
=
"
MergeRequest
"
,
description
=
"合并请求体"
)
public
class
MergeRequest
{
@ApiModelProperty
(
value
=
"name"
,
notes
=
"合成后的文件名称
"
)
@ApiModelProperty
(
name
=
"name"
,
value
=
"合成后的文件名称"
,
notes
=
"合成后的文件名称"
,
example
=
"1.zip
"
)
private
String
name
;
//文件
@ApiModelProperty
(
value
=
"md5File
"
,
notes
=
"MD5生成的文件夹名称"
,
example
=
"fc44454f994403b01b40895f0a6535b5"
)
@ApiModelProperty
(
name
=
"md5File"
,
value
=
"MD5生成的文件夹名称
"
,
notes
=
"MD5生成的文件夹名称"
,
example
=
"fc44454f994403b01b40895f0a6535b5"
)
private
String
md5File
;
//md5文件
@ApiModelProperty
(
value
=
"chuck
"
,
notes
=
"当前分片"
,
example
=
"1"
)
@ApiModelProperty
(
name
=
"chuck"
,
value
=
"当前分片
"
,
notes
=
"当前分片"
,
example
=
"1"
)
private
Integer
chuck
;
//分片
}
efs-ftp/src/main/java/com/zjty/efs/ftp/entity/MergeResponse.java
浏览文件 @
6cab523d
...
...
@@ -12,12 +12,12 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Data
@ApiModel
(
value
=
"
合并
"
,
description
=
"合并响应体"
)
@ApiModel
(
value
=
"
MergeResponse
"
,
description
=
"合并响应体"
)
public
class
MergeResponse
{
@ApiModelProperty
(
value
=
"name
"
,
notes
=
"上传文件名称"
,
example
=
"1.zip"
)
@ApiModelProperty
(
name
=
"name"
,
value
=
"上传文件名称
"
,
notes
=
"上传文件名称"
,
example
=
"1.zip"
)
private
String
name
;
//上传文件的名称
@ApiModelProperty
(
value
=
"path
"
,
notes
=
"上传文件服务器中存储地址"
,
example
=
"D://file/uploads/1.zip"
)
@ApiModelProperty
(
name
=
"path"
,
value
=
"上传文件服务器中存储地址
"
,
notes
=
"上传文件服务器中存储地址"
,
example
=
"D://file/uploads/1.zip"
)
private
String
path
;
//上传文件的地址
@ApiModelProperty
(
value
=
"saveSuccess
"
,
notes
=
"文件保存是否成功 0-失败 1-成功"
,
example
=
"1"
)
@ApiModelProperty
(
name
=
"saveSuccess"
,
value
=
"文件保存是否成功
"
,
notes
=
"文件保存是否成功 0-失败 1-成功"
,
example
=
"1"
)
private
int
saveSuccess
;
//文件保存是否成功 0-失败 1-成功
}
efs-ftp/src/main/java/com/zjty/efs/ftp/entity/UploadRequest.java
浏览文件 @
6cab523d
package
com
.
zjty
.
efs
.
ftp
.
entity
;
import
com.zjty.efs.misc.config.AutoDocument
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
...
...
@@ -13,12 +12,12 @@ import org.springframework.web.multipart.MultipartFile;
@AllArgsConstructor
@NoArgsConstructor
@Data
@ApiModel
(
value
=
"
文件上传
"
,
description
=
"文件上传请求体"
)
@ApiModel
(
value
=
"
UploadRequest
"
,
description
=
"文件上传请求体"
)
public
class
UploadRequest
{
@ApiModelProperty
(
value
=
"multipartFile
"
,
notes
=
"文件数据"
)
@ApiModelProperty
(
name
=
"multipartFile"
,
value
=
"文件数据
"
,
notes
=
"文件数据"
)
private
MultipartFile
multipartFile
;
//文件
@ApiModelProperty
(
value
=
"md5File
"
,
notes
=
"MD5生成的文件夹名称"
,
example
=
"fc44454f994403b01b40895f0a6535b5"
)
@ApiModelProperty
(
name
=
"md5File"
,
value
=
"MD5生成的文件夹名称
"
,
notes
=
"MD5生成的文件夹名称"
,
example
=
"fc44454f994403b01b40895f0a6535b5"
)
private
String
md5File
;
//md5文件
@ApiModelProperty
(
value
=
"chuck
"
,
notes
=
"当前分片"
,
example
=
"1"
)
@ApiModelProperty
(
name
=
"chuck"
,
value
=
"当前分片
"
,
notes
=
"当前分片"
,
example
=
"1"
)
private
Integer
chuck
;
//分片
}
efs-ftp/src/main/java/com/zjty/efs/ftp/service/FileUploadService.java
浏览文件 @
6cab523d
...
...
@@ -35,7 +35,7 @@ public interface FileUploadService {
* @author zs
* 修改上传
*/
ServerResponse
upload
(
List
<
UploadRequest
>
uploadRequests
);
ServerResponse
upload
(
MultipartFile
file
,
String
md5File
,
Integer
chunk
);
/**
* @author zs
...
...
efs-ftp/src/main/java/com/zjty/efs/ftp/service/impl/FileDownLoadServiceImpl.java
浏览文件 @
6cab523d
...
...
@@ -28,7 +28,7 @@ public class FileDownLoadServiceImpl implements FileDownLoadService {
* @param response
* 响应对象
* @param fileName
* 文件名称
(绝对)
* 文件名称
*/
public
void
fileDownLoad
(
String
fileName
,
HttpServletResponse
response
,
HttpServletRequest
httpServletRequest
)
{
if
(
fileName
!=
null
){
...
...
@@ -39,13 +39,12 @@ public class FileDownLoadServiceImpl implements FileDownLoadService {
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
File
file
=
new
File
(
fileAddress
+
"/"
+
fileName
);
String
path
=
fileAddress
+
"/"
+
fileName
;
File
file
=
new
File
(
path
);
long
fileLength
=
file
.
length
();
response
.
setHeader
(
"Content-Length"
,
fileLength
+
""
);
//如果文件存在,返回文件,文件不存在,返回文件不存在提示
boolean
fileExist
=
false
;
if
(
file
.
length
()
!=
0
){
fileExist
=
true
;
}
if
(
fileExist
){
if
(
fileLength
!=
0
){
setFileDownloadHeader
(
httpServletRequest
,
response
,
fileName
);
OutputStream
os
=
null
;
InputStream
is
=
null
;
...
...
@@ -62,8 +61,10 @@ public class FileDownLoadServiceImpl implements FileDownLoadService {
}
os
.
flush
();
}
catch
(
FileNotFoundException
e
)
{
log
.
error
(
file
.
getAbsolutePath
()
+
"文件不存在"
);
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
log
.
error
(
file
.
getAbsolutePath
()
+
"文件读取异常"
);
e
.
printStackTrace
();
}
finally
{
try
{
...
...
@@ -71,12 +72,15 @@ public class FileDownLoadServiceImpl implements FileDownLoadService {
is
.
close
();
os
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
log
.
error
(
"用户终止下载"
);
//e.printStackTrace();
}
}
}
else
{
log
.
info
(
"该文件不存在"
);
log
.
info
(
path
+
"该文件不存在"
);
}
}
else
{
log
.
error
(
"请求的文件名为空"
);
}
}
...
...
efs-ftp/src/main/java/com/zjty/efs/ftp/service/impl/FileUploadServiceImpl.java
浏览文件 @
6cab523d
...
...
@@ -122,12 +122,7 @@ public class FileUploadServiceImpl implements FileUploadService {
}
@Override
public
ServerResponse
upload
(
List
<
UploadRequest
>
uploadRequests
)
{
if
(
uploadRequests
!=
null
&&
uploadRequests
.
size
()
!=
0
){
for
(
UploadRequest
uploadRequest:
uploadRequests
){
String
md5File
=
uploadRequest
.
getMd5File
();
Integer
chunk
=
uploadRequest
.
getChuck
();
MultipartFile
file
=
uploadRequest
.
getMultipartFile
();
public
ServerResponse
upload
(
MultipartFile
file
,
String
md5File
,
Integer
chunk
)
{
String
chunkPath
=
fileAddress
+
"/"
+
md5File
+
"/"
;
//分片存放目录
File
dirFile
=
new
File
(
chunkPath
);
if
(!
dirFile
.
exists
())
{
//目录不存在,创建目录
...
...
@@ -140,7 +135,7 @@ public class FileUploadServiceImpl implements FileUploadService {
chunkName
=
chunk
+
".tmp"
;
}
String
filePath
=
chunkPath
+
chunkName
;
File
saveFile
=
new
File
(
filePath
);
File
saveFile
=
new
File
(
new
File
(
filePath
).
getAbsolutePath
()
);
try
{
if
(!
saveFile
.
exists
())
{
saveFile
.
createNewFile
();
//文件不存在,则创建
...
...
@@ -149,8 +144,6 @@ public class FileUploadServiceImpl implements FileUploadService {
}
catch
(
IOException
e
)
{
log
.
error
(
filePath
+
"文件没有保存"
);
}
}
}
return
ServerResponse
.
success
(
"true"
);
}
...
...
efs-union/src/main/resources/application.properties
浏览文件 @
6cab523d
...
...
@@ -8,7 +8,7 @@ spring.main.allow-bean-definition-overriding=true
spring.datasource.url
=
jdbc:mysql://localhost:3306/ty_efs?useSSL=false&serverTimezone=UTC&characterEncoding=UTF-8
spring.datasource.driver-class-name
=
com.mysql.jdbc.Driver
spring.datasource.username
=
root
spring.datasource.password
=
ljj123456
spring.datasource.password
=
root
# spring.jpa.properties.hibernate.format_sql=true
spring.jpa.hibernate.ddl-auto
=
update
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论