From 2a64313885db9abd355eb31ef6a1db993bc79ed8 Mon Sep 17 00:00:00 2001
From: liyating <2435065796@qq.com>
Date: Thu, 25 Mar 2021 13:15:19 +0800
Subject: [PATCH 1/4] =?UTF-8?q?README.md=20README.en.md=20=E6=9B=B4?=
=?UTF-8?q?=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.en.md | 207 ++++++++++++++++++++++++++++++++++++++++++---------
README.md | 150 +++++++++++++++++++++----------------
2 files changed, 257 insertions(+), 100 deletions(-)
diff --git a/README.en.md b/README.en.md
index 9f13e99..ffb2d16 100644
--- a/README.en.md
+++ b/README.en.md
@@ -1,37 +1,170 @@
-# qiwen-file
-
-#### Description
-文件管理系统(仿百度网盘)
-基于springboot + vue 框架开发的Web文件系统,旨在为用户提供一个简单、方便的文件存储方案
-
-#### Software Architecture
-Software architecture description
-
-#### Installation
-
-1. xxxx
-2. xxxx
-3. xxxx
-
-#### Instructions
-
-1. xxxx
-2. xxxx
-3. xxxx
-
-#### Contribution
-
-1. Fork the repository
-2. Create Feat_xxx branch
-3. Commit your code
-4. Create Pull Request
-
-
-#### Gitee Feature
-
-1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
-2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
-3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
-4. The most valuable open source project [GVP](https://gitee.com/gvp)
-5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
-6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
+
+
+
+
+ The distributed file system based on Spring Boot + VUE CLI@3 framework is designed to provide a simple and convenient file storage scheme for users and enterprises. It can manage files with a perfect directory structure system.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Online presentation environment |
+ Installation instructions |
+ Update log
+
+
+---
+
+## Open source that
+
+System 100% open source
+The software follows the MIT open source protocol
+
+**You can build on it to improve its functionality and become a contributor to this project**
+
+**You can also use this project as a scaffold for other projects**
+
+## Function is introduced
+
+### The user action
+
+1. User login and registration
+
+### File operations
+
+1. Users can add, delete and modify the directory structure
+2. Provide uploading and downloading of files.
+3. Support online decompression of ZIP files and RAR files
+4. Support files and directories to move and copy
+5. Classified view of multiple file formats
+6. Support AliCloud OSS object storage and FastDFS storage
+7. Added sharding uploading, which supports local storage, Ali Cloud OSS and FastDFS
+8. Support high speed second transmission function to improve uploading efficiency
+9. The foreground of uploading files displays the progress, rate, percentage and other information of uploading files in real time
+10. Support file renaming
+11. Display file storage and total capacity in real time
+12. Support ElasticSearch file search
+13. ...
+
+## The source address
+
+| The project name | The source address |
+| ---------------------- | -------------------------------------------------------------------------------------------- |
+| The front project | [https://gitee.com/qiwen-cloud/qiwen-file-web](https://gitee.com/qiwen-cloud/qiwen-file-web) |
+| The background project | [https://gitee.com/qiwen-cloud/qiwen-file](https://gitee.com/qiwen-cloud/qiwen-file) |
+
+## Network topology
+
+
+
+## Software architecture
+
+The project was developed and deployed in a front-end separation approach, using the following key technologies
+
+**Front**:Element UI、Vue CLI@3、Node.js、Webpack
+
+**Background **:Spring Boot、MyBatis、JPA、JWT
+
+**Database** : MySQL
+
+**Data Structure**:Recursive algorithms, tree traversal and insertion...
+
+## Directions for use
+
+1、This project is the back-end code
+
+2、Download the front-end code, you can access the address to pull:[qiwen-file-web](https://gitee.com/qiwen-cloud/qiwen-file-web)
+
+## Screenshots of some functions
+
+### 1. The cloud home page
+
+#### 1.1 The page layout
+
+- **Left menu bar area:** display file type, click to view files by category, the bottom shows the occupied storage space.
+- **Top file operation area:** including operation button group for files, switch button group for file viewing mode, and set button for file display column.
+- **Right file display area:** including breadcrumb navigation bar -- identifies the directory currently located; File display area -- the display format will change according to the file viewing mode; Bottom paging component.
+
+
+
+#### 1.2 Layout adjustment function
+
+The left menu bar is collapsible, and the table operation column is collapsible. You can control the display and hiding of the columns in the current table.
+
+
+
+#### 1.3 Batch operation function
+
+
+
+### 2. Three viewing modes
+
+File viewing supports three presentation modes (list, grid, and timeline)
+
+#### 2.1 List Mode
+
+
+
+#### 2.2 Grid Mode
+
+
+
+#### 2.3 Timeline Mode
+
+
+
+### 3. Create a folder
+
+
+
+### 5. Move files
+
+
+
+### 6. Online file decompression
+
+
+
+### 7. File upload
+
+文件采用**分片上传**,集成了[simiple-uplader](https://github.com/simple-uploader/Uploader/blob/develop/README_zh-CN.md#uploader)的文件**秒传**、**断点续传**功能。
+
+
+### 8. Document Recycle Bin
+
+
+
+## Contact us
+
+If you have any questions, please join the QQ group consultation
+
+**QQ communication group ** and **WeChat public account** please scan the following QR code
+
+
+

+

+
+
+## Participate in the contribution
+
+1. Fork the warehouse
+2. Create a new branch: Feat_xxx
+3. Submit code
+4. Create a new Pull Request
+
+## Gitee Special Effects
+
+1. Use Readme_XXX.md to support different languages,for example: Readme_en.md,Readme_zh.md
+2. The official blog of Gitee: [blog.gitee.com](https://blog.gitee.com)
+3. You can be in [https://gitee.com/explore](https://gitee.com/explore) here to decode the cloud good open source project
+4. [GVP](https://gitee.com/gvp) The full name is the most valuable open source project of Gitee, and the excellent open source project comprehensively evaluated by Gitee
+5. The Gitee official user's manual: [https://gitee.com/help](https://gitee.com/help)
+6. The Gitee cover figure is a column used to show the elegant demeanor of Code Cloud members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
diff --git a/README.md b/README.md
index 65cf692..3bf5ae6 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,3 @@
-
@@ -22,111 +21,137 @@
更新日志
--------------------------------------------------------------------------------
+---
## 开源说明
-系统100%开源
-本软件遵循MIT开源协议
- **您可以在其基础上继续进行开发来完善其功能,成为本项目的贡献者之一**
+系统 100%开源
+本软件遵循 MIT 开源协议
- **您也可以以该项目作为脚手架,进行其他项目的开发**
+**您可以在其基础上继续进行开发来完善其功能,成为本项目的贡献者之一**
+
+**您也可以以该项目作为脚手架,进行其他项目的开发**
+
+## 功能介绍
+
+### 用户操作
-## 功能
-#### 用户操作
1. 用户的登录和注册
-#### 文件操作
-1. 用户可对目录结构进行增加,删除,修改
-2. 提供文件的上传,下载,
-3. 支持对zip文件和rar文件的在线解压缩
-4. 支持文件和目录的移动和复制
+
+### 文件操作
+
+1. 用户可对目录结构进行增加,删除,修改
+2. 提供文件的上传,下载,
+3. 支持对 zip 文件和 rar 文件的在线解压缩
+4. 支持文件和目录的移动和复制
5. 多文件格式分类查看
-6. 支持阿里云OSS对象存储,FastDFS存储
-7. 增加分片上传,该功能同时支持本地存储和阿里云OSS,FastDFS
+6. 支持阿里云 OSS 对象存储,FastDFS 存储
+7. 增加分片上传,该功能同时支持本地存储和阿里云 OSS,FastDFS
8. 支持极速秒传功能,提高上传效率
9. 上传文件前台实时显示上传文件进度,上传速率,百分比等信息
10. 支持文件重命名
11. 可实时显示文件存储占用情况及总占用容量
-12. 支持ElasticSearch文件搜索
-13. ...
+12. 支持 ElasticSearch 文件搜索
+13. .……
-## 项目代码地址
-|系统|地址|
-|-|-|
-|奇文网盘前台|[https://gitee.com/qiwen-cloud/qiwen-file-web](https://gitee.com/qiwen-cloud/qiwen-file-web)|
-|奇文网盘后台|[https://gitee.com/qiwen-cloud/qiwen-file](https://gitee.com/qiwen-cloud/qiwen-file)|
+## 源码地址
+
+| 项目名称 | 源码地址 |
+| ------------ | -------------------------------------------------------------------------------------------- |
+| 奇文网盘前端 | [https://gitee.com/qiwen-cloud/qiwen-file-web](https://gitee.com/qiwen-cloud/qiwen-file-web) |
+| 奇文网盘后台 | [https://gitee.com/qiwen-cloud/qiwen-file](https://gitee.com/qiwen-cloud/qiwen-file) |
## 网络拓扑图
-
+
## 软件架构
+
该项目采用前后端分离的方式进行开发和部署,主要用到以下关键技术
-**前台**:elementui,vue-cli3, swipper, nodejs, webpack
+**前台**:Element UI、Vue CLI@3、Node.js、Webpack
-**后台**:springboot mybatis jpa jwt
+**后台**:Spring Boot、MyBatis、JPA、JWT
-**数据库** : mysql
+**数据库** : MySQL
**数据结构**:递归算法,树的遍历和插入...
-
## 使用说明
+
1、本项目为后端代码
-2、下载前台代码,可以访问该地址进行拉取
-前台代码源码:[源码](https://gitee.com/qiwen-cloud/qiwen-file-web)
+2、下载前端代码,可以访问该地址进行拉取:[qiwen-file-web](https://gitee.com/qiwen-cloud/qiwen-file-web)
+## 部分功能截图
+### 1. 网盘主页
-## 部分功能演示截图
- **主页** :yellow_heart:
-
+#### 1.1 页面布局
-
+- **左侧菜单栏区域:**展示文件类型,点击可以分类查看文件,底部显示已占用存储空间。
+- **顶部文件操作区域:**包括对文件的操作按钮组、文件查看模式切换按钮组、设置文件显示列按钮。
+- **右侧文件展示区域:**包括面包屑导航栏——标识当前位于的目录;文件展示区域——展示形式会随文件查看模式而改变;底部分页组件。
-
+
- **文件分类查看** :heart:
+#### 1.2 布局调整功能
-支持三种显示格式进行查看(列表,网格,时间线)
+左侧菜单栏可折叠,表格操作列可折叠,可控制当前表格中列的显示和隐藏
-列表
-
-网格
-
-时间线
-
+
- **创建文件夹** :blue_heart:
-
- **操作列展示** :purple_heart:
-
+#### 1.3 批量操作功能
-
- **文件的复制和移动** :heart:
-
- **文件在线解压缩** :green_heart:
-
- **上传进度显示**
-
- **上传进度框最小化**
-
+
+### 2. 三种查看模式
-## 联系我
-各种问题可扫描加入QQ群进行咨询
+文件查看支持三种展示模式(列表、网格和时间线模式)
-**QQ交流群**请扫描下面二维码
+#### 2.1 列表模式
-
+
-**微信公众号**请扫描下面二维码
+#### 2.2 网格模式
-
+
+#### 2.3 时间线模式
+
+
+### 3. 创建文件夹
+
+
+
+### 5. 文件移动
+
+
+
+### 6. 文件在线解压缩
+
+
+
+### 7. 文件上传
+
+文件采用**分片上传**,集成了[simiple-uplader](https://github.com/simple-uploader/Uploader/blob/develop/README_zh-CN.md#uploader)的文件**秒传**、**断点续传**功能。
+
+
+### 8. 文件回收站
+
+
+
+## 联系我们
+
+如您有问题,请加入 QQ 群咨询
+
+**QQ 交流群**和**微信公众号**请扫描下面二维码
+
+
+

+

+
## 参与贡献
@@ -135,10 +160,9 @@
3. 提交代码
4. 新建 Pull Request
-
## 码云特技
-1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
+1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目
From 847555b577e420435933e10632e8996d5a368d53 Mon Sep 17 00:00:00 2001
From: liyating <2435065796@qq.com>
Date: Thu, 25 Mar 2021 13:39:01 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20README.md=20README.en.?=
=?UTF-8?q?md?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.en.md | 5 +++--
README.md | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/README.en.md b/README.en.md
index ffb2d16..b80e356 100644
--- a/README.en.md
+++ b/README.en.md
@@ -149,10 +149,11 @@ If you have any questions, please join the QQ group consultation
**QQ communication group ** and **WeChat public account** please scan the following QR code
+
## Participate in the contribution
1. Fork the warehouse
diff --git a/README.md b/README.md
index 3bf5ae6..8fb5f46 100644
--- a/README.md
+++ b/README.md
@@ -149,10 +149,11 @@
**QQ 交流群**和**微信公众号**请扫描下面二维码
+
## 参与贡献
1. Fork 本仓库
From 8177a0971930d2a81e14b76e208527b8c56fa6ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=A9=AC=E8=B6=85?=
Date: Thu, 25 Mar 2021 19:40:55 +0800
Subject: [PATCH 3/4] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../common/config/PropertiesConfig.java | 20 +++++
.../common/config/PropertiesUtil.java | 18 +++++
.../common/config/QiwenFileConfig.java | 1 +
.../common/operation/upload/Uploader.java | 12 ++-
.../com/qiwenshare/file/api/IFileService.java | 7 --
.../file/controller/FileController.java | 9 ---
.../controller/FiletransferController.java | 76 +------------------
.../com/qiwenshare/file/domain/UserFile.java | 2 +-
.../qiwenshare/file/service/FileService.java | 76 -------------------
.../resources/config/application.properties | 5 +-
10 files changed, 58 insertions(+), 168 deletions(-)
create mode 100644 file-common/src/main/java/com/qiwenshare/common/config/PropertiesConfig.java
create mode 100644 file-common/src/main/java/com/qiwenshare/common/config/PropertiesUtil.java
diff --git a/file-common/src/main/java/com/qiwenshare/common/config/PropertiesConfig.java b/file-common/src/main/java/com/qiwenshare/common/config/PropertiesConfig.java
new file mode 100644
index 0000000..04d1982
--- /dev/null
+++ b/file-common/src/main/java/com/qiwenshare/common/config/PropertiesConfig.java
@@ -0,0 +1,20 @@
+package com.qiwenshare.common.config;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.env.Environment;
+
+@Configuration
+public class PropertiesConfig {
+
+ @Resource
+ private Environment env;
+
+ @PostConstruct
+ public void setProperties() {
+ PropertiesUtil.setEnvironment(env);
+ }
+
+}
\ No newline at end of file
diff --git a/file-common/src/main/java/com/qiwenshare/common/config/PropertiesUtil.java b/file-common/src/main/java/com/qiwenshare/common/config/PropertiesUtil.java
new file mode 100644
index 0000000..5cae131
--- /dev/null
+++ b/file-common/src/main/java/com/qiwenshare/common/config/PropertiesUtil.java
@@ -0,0 +1,18 @@
+package com.qiwenshare.common.config;
+
+import org.springframework.core.env.Environment;
+
+public class PropertiesUtil {
+
+ private static Environment env = null;
+
+ public static void setEnvironment(Environment env) {
+ PropertiesUtil.env = env;
+ }
+
+ public static String getProperty(String key) {
+ return PropertiesUtil.env.getProperty(key);
+ }
+
+
+}
\ No newline at end of file
diff --git a/file-common/src/main/java/com/qiwenshare/common/config/QiwenFileConfig.java b/file-common/src/main/java/com/qiwenshare/common/config/QiwenFileConfig.java
index 5cbeaaf..b721e37 100644
--- a/file-common/src/main/java/com/qiwenshare/common/config/QiwenFileConfig.java
+++ b/file-common/src/main/java/com/qiwenshare/common/config/QiwenFileConfig.java
@@ -13,6 +13,7 @@ public class QiwenFileConfig {
private String storageType;
private String cacheMode;
+ private String localStoragePath;
private AliyunConfig aliyun = new AliyunConfig();
diff --git a/file-common/src/main/java/com/qiwenshare/common/operation/upload/Uploader.java b/file-common/src/main/java/com/qiwenshare/common/operation/upload/Uploader.java
index daedc7c..2dec65c 100644
--- a/file-common/src/main/java/com/qiwenshare/common/operation/upload/Uploader.java
+++ b/file-common/src/main/java/com/qiwenshare/common/operation/upload/Uploader.java
@@ -1,9 +1,11 @@
package com.qiwenshare.common.operation.upload;
+import com.qiwenshare.common.config.PropertiesUtil;
import com.qiwenshare.common.domain.UploadFile;
import com.qiwenshare.common.util.PathUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
@@ -14,9 +16,11 @@ import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
+import java.util.ResourceBundle;
@Slf4j
public abstract class Uploader {
+
public static final String ROOT_PATH = "upload";
public static final String FILE_SEPARATOR = "/";
@@ -31,10 +35,16 @@ public abstract class Uploader {
* @return
*/
protected String getSaveFilePath() {
+
String path = ROOT_PATH;
SimpleDateFormat formater = new SimpleDateFormat("yyyyMMdd");
path = FILE_SEPARATOR + path + FILE_SEPARATOR + formater.format(new Date());
- File dir = new File(PathUtil.getStaticPath() + path);
+ String localStoragePath = PropertiesUtil.getProperty("qiwen-file.local-storage-path");
+ String staticPath = PathUtil.getStaticPath();
+ if (StringUtils.isNotEmpty(localStoragePath)) {
+ staticPath = localStoragePath;
+ }
+ File dir = new File(staticPath + path);
//LOG.error(PathUtil.getStaticPath() + path);
if (!dir.exists()) {
try {
diff --git a/file-web/src/main/java/com/qiwenshare/file/api/IFileService.java b/file-web/src/main/java/com/qiwenshare/file/api/IFileService.java
index 3ef2ab9..f4f815d 100644
--- a/file-web/src/main/java/com/qiwenshare/file/api/IFileService.java
+++ b/file-web/src/main/java/com/qiwenshare/file/api/IFileService.java
@@ -9,17 +9,10 @@ import java.util.List;
public interface IFileService extends IService {
-
-// void batchInsertFile(List fileBeanList, Long userId);
- //void updateFile(FileBean fileBean);
-
void increaseFilePointCount(Long fileId);
void decreaseFilePointCount(Long fileId);
-// List selectFileListByPath(FileBean fileBean);
-
-// void deleteLocalFile(FileBean fileBean);
diff --git a/file-web/src/main/java/com/qiwenshare/file/controller/FileController.java b/file-web/src/main/java/com/qiwenshare/file/controller/FileController.java
index 335b3c9..2f89b1d 100644
--- a/file-web/src/main/java/com/qiwenshare/file/controller/FileController.java
+++ b/file-web/src/main/java/com/qiwenshare/file/controller/FileController.java
@@ -164,10 +164,6 @@ public class FileController {
} else {
FileBean file = fileService.getById(userFile.getFileId());
if (file.getIsOSS() == 1 || file.getStorageType() == 1) {
-// LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>();
-// lambdaQueryWrapper.eq(UserFile::getUserFileId, renameFileDto.getUserFileId());
-// UserFile userFile = userFileService.getOne(lambdaQueryWrapper);
-
String fileUrl = file.getFileUrl();
String newFileUrl = fileUrl.replace(userFile.getFileName(), renameFileDto.getFileName());
@@ -297,12 +293,7 @@ public class FileController {
}
UserBean sessionUserBean = userService.getUserBeanByToken(token);
-// String uuid = UUID.randomUUID().toString();
-// UserFile userFile = new UserFile();
-// userFile.setUserFileId(deleteFileDto.getUserFileId());
-//// userFile.setDeleteBatchNum(uuid);
-// BeanUtil.copyProperties(deleteFileDto, userFile);
userFileService.deleteUserFile(deleteFileDto.getUserFileId(), sessionUserBean.getUserId());
diff --git a/file-web/src/main/java/com/qiwenshare/file/controller/FiletransferController.java b/file-web/src/main/java/com/qiwenshare/file/controller/FiletransferController.java
index 1c5e573..7a7a3b1 100644
--- a/file-web/src/main/java/com/qiwenshare/file/controller/FiletransferController.java
+++ b/file-web/src/main/java/com/qiwenshare/file/controller/FiletransferController.java
@@ -1,18 +1,14 @@
package com.qiwenshare.file.controller;
-import com.github.tobato.fastdfs.proto.storage.DownloadByteArray;
-import com.github.tobato.fastdfs.service.FastFileStorageClient;
-import com.qiwenshare.common.util.DateUtil;
-import com.qiwenshare.common.operation.FileOperation;
-import com.qiwenshare.common.util.FileUtil;
+import com.qiwenshare.common.config.QiwenFileConfig;
import com.qiwenshare.common.result.RestResult;
-import com.qiwenshare.common.util.PathUtil;
+import com.qiwenshare.common.util.DateUtil;
+import com.qiwenshare.common.util.FileUtil;
import com.qiwenshare.file.anno.MyLog;
import com.qiwenshare.file.api.IFileService;
import com.qiwenshare.file.api.IFiletransferService;
import com.qiwenshare.file.api.IUserFileService;
import com.qiwenshare.file.api.IUserService;
-import com.qiwenshare.common.config.QiwenFileConfig;
import com.qiwenshare.file.domain.FileBean;
import com.qiwenshare.file.domain.StorageBean;
import com.qiwenshare.file.domain.UserBean;
@@ -26,10 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
-import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.io.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -53,8 +47,6 @@ public class FiletransferController {
IUserService userService;
@Resource
IUserFileService userFileService;
- @Autowired
- private FastFileStorageClient fastFileStorageClient;
public static final String CURRENT_MODULE = "文件传输接口";
@Operation(summary = "极速上传", description = "校验文件MD5判断文件是否存在,如果存在直接上传成功并返回skipUpload=true,如果不存在返回skipUpload=false需要再次调用该接口的POST方法", tags = {"filetransfer"})
@@ -142,68 +134,6 @@ public class FiletransferController {
filetransferService.downloadFile(response, downloadFileDTO);
}
- private void localFileDownload(HttpServletResponse response, FileBean fileBean) {
- BufferedInputStream bis = null;
- byte[] buffer = new byte[1024];
- //设置文件路径
- File file = FileOperation.newFile(PathUtil.getStaticPath() + fileBean.getFileUrl());
- if (file.exists()) {
-
-
- FileInputStream fis = null;
-
- try {
- fis = new FileInputStream(file);
- bis = new BufferedInputStream(fis);
- OutputStream os = response.getOutputStream();
- int i = bis.read(buffer);
- while (i != -1) {
- os.write(buffer, 0, i);
- i = bis.read(buffer);
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (bis != null) {
- try {
- bis.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
- }
-
-
-
-
- public void fastFDSDownload(HttpServletResponse response, FileBean fileBean){
- String group = fileBean.getFileUrl().substring(0, fileBean.getFileUrl().indexOf("/"));
- String path = fileBean.getFileUrl().substring(fileBean.getFileUrl().indexOf("/") + 1);
- DownloadByteArray downloadByteArray = new DownloadByteArray();
- byte[] bytes = fastFileStorageClient.downloadFile(group, path, downloadByteArray);
-
-// // 这里只是为了整合fastdfs,所以写死了文件格式。需要在上传的时候保存文件名。下载的时候使用对应的格式
-// response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("sb.xlsx", "UTF-8"));
-// response.setCharacterEncoding("UTF-8");
- ServletOutputStream outputStream = null;
- try {
- outputStream = response.getOutputStream();
- outputStream.write(bytes);
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- try {
- outputStream.flush();
- outputStream.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
@Operation(summary = "获取存储信息", description = "获取存储信息", tags = {"filetransfer"})
@RequestMapping(value = "/getstorage", method = RequestMethod.GET)
diff --git a/file-web/src/main/java/com/qiwenshare/file/domain/UserFile.java b/file-web/src/main/java/com/qiwenshare/file/domain/UserFile.java
index 7d47b41..a50b6ba 100644
--- a/file-web/src/main/java/com/qiwenshare/file/domain/UserFile.java
+++ b/file-web/src/main/java/com/qiwenshare/file/domain/UserFile.java
@@ -9,7 +9,7 @@ import javax.persistence.*;
@Data
@Table(name = "userfile", uniqueConstraints = {
- @UniqueConstraint(name = "fileindex", columnNames = {"fileName", "filePath", "extendName", "deleteFlag"})})
+ @UniqueConstraint(name = "fileindex", columnNames = {"fileName", "filePath", "extendName", "deleteFlag", "userId"})})
@Entity
@TableName("userfile")
public class UserFile {
diff --git a/file-web/src/main/java/com/qiwenshare/file/service/FileService.java b/file-web/src/main/java/com/qiwenshare/file/service/FileService.java
index 2f70c77..e6eb186 100644
--- a/file-web/src/main/java/com/qiwenshare/file/service/FileService.java
+++ b/file-web/src/main/java/com/qiwenshare/file/service/FileService.java
@@ -1,14 +1,10 @@
package com.qiwenshare.file.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.github.tobato.fastdfs.service.FastFileStorageClient;
import com.qiwenshare.file.api.IFileService;
-import com.qiwenshare.common.config.QiwenFileConfig;
import com.qiwenshare.file.domain.FileBean;
import com.qiwenshare.file.mapper.FileMapper;
-import com.qiwenshare.file.mapper.UserFileMapper;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -19,32 +15,7 @@ public class FileService extends ServiceImpl implements IF
@Resource
FileMapper fileMapper;
- @Resource
- UserFileMapper userFileMapper;
- @Resource
- FiletransferService filetransferService;
- @Resource
- QiwenFileConfig qiwenFileConfig;
- @Autowired
- private FastFileStorageClient fastFileStorageClient;
-// @Override
-// public void batchInsertFile(List fileBeanList, Long userId) {
-// StorageBean storageBean = filetransferService.selectStorageBean(new StorageBean(userId));
-// long fileSizeSum = 0;
-// for (FileBean fileBean : fileBeanList) {
-// if (fileBean.getIsDir() == 0) {
-// fileSizeSum += fileBean.getFileSize();
-// }
-// }
-// fileMapper.batchInsertFile(fileBeanList);
-// if (storageBean != null) {
-// long updateFileSize = storageBean.getStorageSize() + fileSizeSum;
-//
-// storageBean.setStorageSize(updateFileSize);
-// filetransferService.updateStorageBean(storageBean);
-// }
-// }
@Override
public void increaseFilePointCount(Long fileId) {
@@ -60,52 +31,5 @@ public class FileService extends ServiceImpl implements IF
fileMapper.updateById(fileBean);
}
-// @Override
-// public void updateFile(FileBean fileBean) {
-// fileBean.setUploadTime(DateUtil.getCurrentTime());
-// fileMapper.updateFile(fileBean);
-// }
-
-
-
-
-// @Override
-// public List selectFileListByPath(FileBean fileBean) {
-// LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>();
-// lambdaQueryWrapper.eq(FileBean::getFilePath, fileBean.getFilePath())
-// .eq(FileBean::getUserId, fileBean.getUserId())
-// .orderByDesc(FileBean::getIsDir);
-// return fileMapper.selectList(lambdaQueryWrapper);
-// }
-// @Override
-// public void deleteLocalFile(FileBean fileBean) {
-// log.info("删除本地文件:" + JSON.toJSONString(fileBean));
-// //删除服务器文件
-// if (fileBean.getFileUrl() != null && fileBean.getFileUrl().indexOf("upload") != -1){
-// if (fileBean.getIsOSS() != null && fileBean.getIsOSS() == 1) {
-// AliyunOSSDelete.deleteObject(qiwenFileConfig.getAliyun().getOss(), fileBean.getFileUrl().substring(1));
-// } else if (fileBean.getStorageType() == 0) {
-// FileOperation.deleteFile(PathUtil.getStaticPath() + fileBean.getFileUrl());
-// if (FileUtil.isImageFile(FileUtil.getFileExtendName(fileBean.getFileUrl()))) {
-// FileOperation.deleteFile(PathUtil.getStaticPath() + fileBean.getFileUrl().replace(fileBean.getTimeStampName(), fileBean.getTimeStampName() + "_min"));
-// }
-// } else if (fileBean.getStorageType() == 1) {
-// AliyunOSSDelete.deleteObject(qiwenFileConfig.getAliyun().getOss(), fileBean.getFileUrl().substring(1));
-// } else if (fileBean.getStorageType() == 2){
-// fastFileStorageClient.deleteFile(fileBean.getFileUrl());
-//
-// } else {
-// FileOperation.deleteFile(PathUtil.getStaticPath() + fileBean.getFileUrl());
-// if (FileUtil.isImageFile(FileUtil.getFileExtendName(fileBean.getFileUrl()))) {
-// FileOperation.deleteFile(PathUtil.getStaticPath() + fileBean.getFileUrl().replace(fileBean.getTimeStampName(), fileBean.getTimeStampName() + "_min"));
-// }
-// }
-// }
-// }
-
-
-
-
-
}
diff --git a/file-web/src/main/resources/config/application.properties b/file-web/src/main/resources/config/application.properties
index 1f6ca74..691fa97 100644
--- a/file-web/src/main/resources/config/application.properties
+++ b/file-web/src/main/resources/config/application.properties
@@ -2,6 +2,9 @@ server.port=8080
#环境切换dev/prod
spring.profiles.active=dev
+qiwen-file.local-storage-path=D:/export
+
+
eureka.client.register-with-eureka=false
eureka.client.fetchRegistry=false
#eureka.client.server.waitTimeInMsWhenSyncEmpty=0
@@ -35,7 +38,7 @@ spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.Ph
#静态资源指定
spring.mvc.static-path-pattern=/**
-spring.web.resources.static-locations=classpath:/static
+spring.web.resources.static-locations=classpath:/static,file:${qiwen-file.local-storage-path}
#上传下载
spring.servlet.multipart.max-file-size=2048MB
From 5df6c7fc08ca9602bb1254f4dcd3bab7e6e7a04e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=A9=AC=E8=B6=85?= <1162714483@qq.com>
Date: Thu, 25 Mar 2021 21:23:30 +0800
Subject: [PATCH 4/4] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E9=85=8D?=
=?UTF-8?q?=E7=BD=AE=E6=9C=AC=E5=9C=B0=E5=AD=98=E5=82=A8=E8=B7=AF=E5=BE=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../common/operation/upload/Uploader.java | 6 ++----
.../com/qiwenshare/common/util/PathUtil.java | 19 +++++++++++++------
.../resources/config/application.properties | 3 ++-
3 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/file-common/src/main/java/com/qiwenshare/common/operation/upload/Uploader.java b/file-common/src/main/java/com/qiwenshare/common/operation/upload/Uploader.java
index 2dec65c..ead1d46 100644
--- a/file-common/src/main/java/com/qiwenshare/common/operation/upload/Uploader.java
+++ b/file-common/src/main/java/com/qiwenshare/common/operation/upload/Uploader.java
@@ -39,11 +39,9 @@ public abstract class Uploader {
String path = ROOT_PATH;
SimpleDateFormat formater = new SimpleDateFormat("yyyyMMdd");
path = FILE_SEPARATOR + path + FILE_SEPARATOR + formater.format(new Date());
- String localStoragePath = PropertiesUtil.getProperty("qiwen-file.local-storage-path");
+
String staticPath = PathUtil.getStaticPath();
- if (StringUtils.isNotEmpty(localStoragePath)) {
- staticPath = localStoragePath;
- }
+
File dir = new File(staticPath + path);
//LOG.error(PathUtil.getStaticPath() + path);
if (!dir.exists()) {
diff --git a/file-common/src/main/java/com/qiwenshare/common/util/PathUtil.java b/file-common/src/main/java/com/qiwenshare/common/util/PathUtil.java
index 107cc69..766f8c7 100644
--- a/file-common/src/main/java/com/qiwenshare/common/util/PathUtil.java
+++ b/file-common/src/main/java/com/qiwenshare/common/util/PathUtil.java
@@ -1,5 +1,7 @@
package com.qiwenshare.common.util;
+import com.qiwenshare.common.config.PropertiesUtil;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.util.ResourceUtils;
import java.io.File;
@@ -47,15 +49,20 @@ public class PathUtil {
* @return
*/
public static String getStaticPath() {
- String projectRootAbsolutePath = getProjectRootPath();
+ String localStoragePath = PropertiesUtil.getProperty("qiwen-file.local-storage-path");
+ if (StringUtils.isNotEmpty(localStoragePath)) {
+ return localStoragePath;
+ }else {
+ String projectRootAbsolutePath = getProjectRootPath();
- int index = projectRootAbsolutePath.indexOf("file:");
- if (index != -1){
- projectRootAbsolutePath = projectRootAbsolutePath.substring(0, index);
+ int index = projectRootAbsolutePath.indexOf("file:");
+ if (index != -1) {
+ projectRootAbsolutePath = projectRootAbsolutePath.substring(0, index);
+ }
+
+ return projectRootAbsolutePath + "static" + File.separator;
}
- return projectRootAbsolutePath + "static" + File.separator;
-
}
diff --git a/file-web/src/main/resources/config/application.properties b/file-web/src/main/resources/config/application.properties
index 691fa97..ef622c4 100644
--- a/file-web/src/main/resources/config/application.properties
+++ b/file-web/src/main/resources/config/application.properties
@@ -2,7 +2,8 @@ server.port=8080
#环境切换dev/prod
spring.profiles.active=dev
-qiwen-file.local-storage-path=D:/export
+#本地存储路径
+#qiwen-file.local-storage-path=D:/export
eureka.client.register-with-eureka=false