# 功能描述
实现网盘功能。
配置文件为application-owndisk.yml
提示
(1) 需在application.yml中增加spring.profiles.active中增加owndisk才能激活配置文件
(2) 需设置application-owndisk.yml中的sei.cloud.owndisk.enabled为true才能开启owndisk服务
# 配置一览表
sei:
cloud:
owndisk:
enabled: false #设置为true才开启服务
temp-path: /Users/xiong/Desktop/temp/ #临时文件目录
root-path: /Users/xiong/Desktop/temp/ #正式文件目录
####### 文件大小 配置 ########
spring:
servlet:
multipart:
enabled: true #是否支持批量上传,默认为true
file-size-threshold: 0 #当大于这个阈值时将写入磁盘,否则在内存中,默认为0,一般情况下不用特意修改
max-file-size: 100MB #单个文件的大小上限,设置为-1不限制,默认为1MB
max-request-size: 100MB #单个请求的文件总大小上限,设置为-1不限制,默认为10MB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Service接口
# 第一步 引入包
<dependency>
<groupId>sei-cloud</groupId>
<artifactId>owndisk</artifactId>
</dependency>
1
2
3
4
2
3
4
# 第二步 引入接口
@Resource
OwnDiskService owndiskService;
1
2
2
# 第三步 使用接口
/**
*
* @author xiong
*/
public interface OwnDiskService {
/**
*目录文件查询
* @param json: 目录名称
* @param module: 模块标识
* @param dirs: 要查看的目录列表
* @return ResMsg
* @throws SQLException 异常
* @throws InstantiationException 异常
* @throws IntrospectionException 异常
* @throws IllegalAccessException 异常
* @throws IllegalArgumentException 异常
* @throws InvocationTargetException 异常
*/
ResMsg getList(@NonNull JSONObject json, @NonNull String module, @NonNull List<String> dirs) throws SQLException, InstantiationException, IntrospectionException, IllegalAccessException, IllegalArgumentException, InvocationTargetException;
/**
* 创建目录
* @param json: 目录名称
* @return ResMsg
* @throws IOException 异常
*/
ResMsg makedir(@NonNull JSONObject json) throws IOException;
// /**
// * 修改文件名
// * @param json: 修改内容
// * @return ResMsg
// */
// ResMsg edit(JSONObject json) throws Exception;
/**
* 删除文件
* @param json: 文件路径及名称
* @param module: 模块标识
* @param root: 相对根目录
* @param isGroup: 是否分组删除
* @param list: 要删除的文件或目录列表
* @return ResMsg
* @throws SQLException 异常
* @throws InstantiationException 异常
* @throws IntrospectionException 异常
* @throws IllegalAccessException 异常
* @throws IllegalArgumentException 异常
* @throws InvocationTargetException 异常
*/
ResMsg del(@NonNull JSONArray json, @NonNull String module, @NonNull String root, boolean isGroup, @Nullable List<String> list) throws SQLException, InstantiationException, IntrospectionException, IllegalAccessException, IllegalArgumentException, InvocationTargetException;
/**
* 单文件或多文件下载(多文件会自动打包为zip文件)
* @param json: 文件路径及名称
* @throws IOException 异常
*/
void down(@NonNull JSONObject json) throws IOException;
/**
* 单文件上传
* @param file: 文件流
* @param fileName: 保存的文件名,为null则使用上传文件的文件名
* @param root: 相对根目录
* @param savePath: 保存的路径,为null则使用用户根目录
* @param isGroup: 是否是分组
* @return ResMsg
* @throws IOException 异常
*/
ResMsg upload(@RequestParam("file") MultipartFile file, @Nullable String fileName, @NonNull String root, @Nullable String savePath, boolean isGroup) throws IOException;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Controller接口
# 分组服务接口
@ConditionalOnProperty(name = "sei.cloud.owndisk.enabled", havingValue = "true")
@Api(description = "分组服务")
@RequestMapping("/api/groupdisk")
public class GroupDiskController {
@ApiOperation(value = "目录列表服务",response = ResMsg.class)
@RequestMapping(value = "/query",method = {RequestMethod.POST},produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody ResMsg query(@RequestBody JSONObject json) throws Exception;
@ApiOperation(value = "新建目录服务",response = ResMsg.class)
@RequestMapping(value = "/makedir",method = {RequestMethod.POST},produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody ResMsg makedir(@RequestBody JSONObject json) throws Exception;
@ApiOperation(value = "删除文件或目录服务",response = ResMsg.class)
@RequestMapping(value = "/del",method = {RequestMethod.POST},produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody ResMsg del(@RequestBody JSONArray json) throws Exception;
@ApiOperation(value = "下载文件服务",response = ResMsg.class)
@RequestMapping(value = "/down",method = {RequestMethod.POST})
public void down(@RequestBody JSONObject json) throws Exception;
@ApiOperation(value = "单文件上传服务")
@RequestMapping(value="/upload", method = RequestMethod.POST,produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody ResMsg upload(@ApiParam(value = "MultipartFile文件", required = true) @RequestParam("file") MultipartFile file, String path) throws Exception;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 个人服务接口
@ConditionalOnProperty(name = "sei.cloud.owndisk.enabled", havingValue = "true")
@Api(description = "个人资料库服务")
@RequestMapping("/api/owndisk")
public class OwnDiskController {
@ApiOperation(value = "目录列表服务",response = ResMsg.class)
@RequestMapping(value = "/query",method = {RequestMethod.POST},produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody ResMsg query(@RequestBody JSONObject json) throws Exception;
@ApiOperation(value = "新建目录服务",response = ResMsg.class)
@RequestMapping(value = "/makedir",method = {RequestMethod.POST},produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody ResMsg makedir(@RequestBody JSONObject json) throws Exception;
@ApiOperation(value = "删除文件或目录服务",response = ResMsg.class)
@RequestMapping(value = "/del",method = {RequestMethod.POST},produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody ResMsg del(@RequestBody JSONArray json) throws Exception;
@ApiOperation(value = "下载文件服务",response = ResMsg.class)
@RequestMapping(value = "/down",method = {RequestMethod.POST})
public void down(@RequestBody JSONObject json) throws Exception;
@ApiOperation(value = "单文件上传服务")
@RequestMapping(value="/upload", method = RequestMethod.POST,produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody ResMsg upload(@ApiParam(value = "MultipartFile文件", required = true) @RequestParam("file") MultipartFile file,String path) throws Exception;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
← data通用数据存取组件 code编码组件 →