# springboot超级文件带师 **Repository Path**: huang_jianxi/spring-boot-super-file-manager ## Basic Information - **Project Name**: springboot超级文件带师 - **Description**: 用springboot开发的超级文件带师,很方便的收集文件,比你邮箱快多了,方便多了。 - **Primary Language**: Java - **License**: MulanPSL-1.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 5 - **Forks**: 5 - **Created**: 2020-12-05 - **Last Updated**: 2023-09-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # springboot超级文件带师介绍 ## 概述 欢迎各位大佬、同学、老师观摩这个小玩意,超级文件带师。接下来我将告诉你如何部署该项目。该项目是idea运行环境,maven项目,在idea导入项目后,maven自动解决依赖问题,即可运行,十分方便。 - 支持创建文件夹,并对文件夹进行描述,方便收集文件。 - 描述支持富文本,插入视频、音频、图片、超链接等。 - 支持最多3个参数命名文件名。 - 项目采用axios、vue、springboot 非常好学习 ## 一.配置 ### 1.1 需要配置一下fartherDir ```java package com.lazyfish.superdir.entity; public class FatherDir { // Windows下父文件夹 // private static String path = "D:\\tmp"; // Linux下父文件夹 private static String path = "/root/testdir"; public static String getPath() { return path; } } ``` ### 1.2 设置数据库 需要自行创建application.yml文件并填写以下信息。 ```xml #置服务器信息 server: port: 8088 spring: #mysq1数据库相关配置 datasource: url: jdbc:mysql://127.0.0.1:3306/您的数据库?characterEncoding=UTF-8&serverTimezone=UTC&useSSL=false username: 您的账户 password: 您的密码 driver-class-name: com.mysql.cj.jdbc.Driver resources: static-locations: classpath:templates/ servlet: multipart: max-file-size: 8000MB max-request-size: 8000MB #配置账号密码 a: admin p: 123456 #配置文件存储区 f: /root/testdir ``` ## 二.功能 ### 2.1 页面功能介绍 |页面|功能 | |--|--| | login.html | 登录页面 | | upload.html | 上传页面 | | dirManager.html | 文件夹管理页面 | ### 2.2 登录页面 ![在这里插入图片描述](https://img-blog.csdnimg.cn/20201205205030399.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzM1Mzg5Ng==,size_16,color_FFFFFF,t_70) ### 2.3 文件夹管理页面 ![在这里插入图片描述](https://img-blog.csdnimg.cn/20201205205200661.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzM1Mzg5Ng==,size_16,color_FFFFFF,t_70) #### 2.3.1 创建自定义文件夹 ![输入图片说明](https://images.gitee.com/uploads/images/2020/1217/090759_17202524_8124808.png "屏幕截图.png") ### 2.4 上传页面 #### 2.4.1 等待上传 ![输入图片说明](https://images.gitee.com/uploads/images/2020/1217/091244_d4112f3b_8124808.png "屏幕截图.png") #### 2.4.2 上传成功 ![输入图片说明](https://images.gitee.com/uploads/images/2020/1217/091444_c86114ef_8124808.png "屏幕截图.png") ## 三.测试 ### 3.1 上传测试 上传到本地的目录下 ```java /** * 测试上传 (需要在D:\tmp\下有kkk-kkk.png这个文件) * @throws IOException */ @Test void test_UploadFile() throws IOException { Map map = new HashMap(); File test_file = new File("D:\\tmp\\kkk-kkk.png"); InputStream inputStream = new FileInputStream(test_file); MultipartFile file = new MockMultipartFile(test_file.getName(), inputStream); String name = "test.png"; String originalFilename = name; try { Dir dir = dirService.getDir(60); //创建要上传的路径 File fdir = new File(FatherDir.getPath()+"/"+dir.getName()); File local_file=new File(FatherDir.getPath()+"/"+dir.getName()+"/"+originalFilename); if(local_file.exists()){ map.put("result", "file_exists"); }else{ //文件上传到路径下 FileUtils.copyInputStreamToFile(file.getInputStream(), new File(fdir, originalFilename)); map.put("result", "success"); } } catch (Exception e) { map.put("result", "error"); map.put("msg", e.getMessage()); } System.out.println(map); } ``` ### 3.2 修改文件夹名及描述 ```java /** * 修改文件夹名即描述(需要知道该文件夹的id值) */ @Test void modifyDir() { Dir dir =new Dir(); dir.setName("hello_2"); dir.setIntro("11223344"); dir.setCollect(1); dir.setId(60); dirService.modifyDir(dir); } ``` ## Log v1.0.0(2020-12-14) - 第一版