1 Star 0 Fork 117

有顺 / ufop-spring-boot-starter

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 4.44 KB
一键复制 编辑 原始数据 按行查看 历史
MAC 提交于 2023-08-22 11:17 . 1.2.8

ufop-spring-boot-starter

介绍

UFOP (Unified File Operation Platform) 统一文件操作平台,通过引入该依赖,可以实现文件操作的统一管理

此项目为奇文网盘核心功能,之前有不少人咨询,如何将网盘集成到自己的项目?出于这个目的,就把这块功能剥离出来供大家方便引入,目前实现的主要功能如下:

  1. 本地文件上传、下载,删除,预览,重命名,读文件流,写文件流
  2. 阿里云OSS上传,下载,删除,预览,重命名,读文件流,写文件流
  3. FastDFS上传,下载,删除,预览,重命名,读文件流,写文件流
  4. FastDFS+Redis实现集群化部署
  5. 图片支持缩略图预览

软件架构

安装教程

mvn clean install

使用说明

  1. 引入pom依赖

这里的具体版本号建议引入最新版本

<dependency>
    <groupId>com.qiwenshare</groupId>
    <artifactId>ufop-spring-boot-starter</artifactId>
    <version>{new version}<version>
</dependency>
  1. application.properties配置文件说明

配置磁盘存储方式, 0-本地存储, 1-阿里云OSS存储, 2-fastDFS存储, 3-minio存储, 4-七牛云KODO对象存储

ufop.storage-type=0

当选择0-本地磁盘存储之后,你还可以继续配置本地文件存储路径

ufop.local-storage-path=D://test

当选择1-阿里云OSS存储之后,需要配置阿里云OSS相关信息,

#阿里云oss基本配置
ufop.aliyun.oss.endpoint=
ufop.aliyun.oss.access-key-id=
ufop.aliyun.oss.access-key-secret=
ufop.aliyun.oss.bucket-name=

当选择2-FastDFS存储之后,则需要配置FastDFS服务器信息

#FastDFS配置
fdfs.so-timeout=1501
fdfs.connect-timeout=601
fdfs.thumb-image.width=150
fdfs.thumb-image.height=150
fdfs.tracker-list=127.0.0.1:22122 

其他存储方式可在下方链接查看 https://pan.qiwenshare.com/docs/config/#%E5%AD%98%E5%82%A8%E6%96%B9%E5%BC%8F%E9%85%8D%E7%BD%AE

除了0-本地存储外,其他存储方式需要配置redis信息


# Redis数据库索引(默认为0)
spring.redis.database=0  
# Redis服务器地址
spring.redis.host=127.0.0.1
# Redis服务器连接端口
spring.redis.port=6379
# Redis服务器连接密码(默认为空)
spring.redis.password=ma123456
# 连接池最大连接数(使用负值表示没有限制) 默认 8
spring.redis.lettuce.pool.max-active=8
# 连接池最大阻塞等待时间(使用负值表示没有限制) 默认 -1
spring.redis.lettuce.pool.max-wait=10000
# 连接池中的最大空闲连接 默认 8
spring.redis.lettuce.pool.max-idle=30
# 连接池中的最小空闲连接 默认 0
spring.redis.lettuce.pool.min-idle=10
#连接超时时间(毫秒)
spring.redis.timeout=5000

当配置完基础信息之后,使用就非常简单了,伪代码如下:

注入UFOPFactory

@Resource
UFOPFactory ufopFactory;

上传文件操作,具体这个上传操作是哪种存储实现,由ufop.storage-type配置项决定,


//上传操作
Uploader uploader = ufopFactory.getUploader();
uploader.upload(request, uploadFile);

下载和删除则需要用户自己传入文件存储类型

//下载操作
Downloader downloader = ufopFactory.getDownloader(fileBean.getStorageType());
downloader.download(httpServletResponse, downloadFile);
//删除操作
Deleter deleter = ufopFactory.getDeleter(fileBean.getStorageType());
deleter.delete(deleteFile);

该工程目前已经在奇文网盘运行了一年多时间,但不免还是会有很多缺陷,如果遇到问题,欢迎大家参与贡献,一块去完善它

参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

特技

  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/
Java
1
https://gitee.com/yaohe/ufop-spring-boot-starter.git
git@gitee.com:yaohe/ufop-spring-boot-starter.git
yaohe
ufop-spring-boot-starter
ufop-spring-boot-starter
master

搜索帮助