feat: 实现文件服务核心功能,支持本地和云存储
实现通用文件上传、存储和访问功能,支持文件去重和多种存储策略。 主要变更: - 新增文件上传接口,支持小文件同步去重、大文件异步处理 - 实现本地存储和腾讯云COS存储策略 - 新增哈希计算服务,支持异步计算大文件哈希 - 新增文件访问控制器,提供文件访问能力 - 扩展附件实体和服务,实现完整的文件管理 - 新增配置类,支持灵活的存储策略切换 - 优化删除状态枚举类型从String改为Integer - 配置文件上传大小限制和存储相关配置 技术细节: - 小文件(<=10MB)同步计算SHA256哈希并去重 - 大文件异步计算哈希,提升上传响应速度 - 支持按日期自动组织文件目录结构 - 集成Hutool工具简化文件操作 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,10 @@ spring:
|
||||
name: file-service
|
||||
profiles:
|
||||
active: @env@
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 500MB
|
||||
max-request-size: 500MB
|
||||
server:
|
||||
port: 10013
|
||||
servlet:
|
||||
@@ -20,8 +24,8 @@ springdoc:
|
||||
operations-sorter: alpha
|
||||
group-configs:
|
||||
- group: 'default'
|
||||
paths-to-match: '/api/**'
|
||||
packages-to-scan: cn.meowrain.aioj.backend.fileservice.controller
|
||||
paths-to-match: '/**'
|
||||
packages-to-scan: cn.meowrain.aioj.backend.fileservice
|
||||
knife4j:
|
||||
basic:
|
||||
enable: true
|
||||
@@ -31,7 +35,48 @@ mybatis-plus:
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
mapper-locations: classpath*:/mapper/**/*.xml
|
||||
aioj:
|
||||
log:
|
||||
enabled: true
|
||||
max-length: 20000
|
||||
|
||||
# 文件存储配置
|
||||
file-config:
|
||||
# 是否使用云存储(true=腾讯云COS,false=本地存储)
|
||||
use-cloud: false
|
||||
# 是否启用文件去重(相同文件只存储一份)
|
||||
deduplication-enabled: true
|
||||
# 同步计算哈希的文件大小阈值(字节),默认 10MB
|
||||
sync-hash-threshold: 10485760
|
||||
# 本地存储配置
|
||||
local:
|
||||
# 本地存储基础路径(相对路径)
|
||||
base-path: uploads
|
||||
# 访问域名(不含context-path)
|
||||
domain: http://localhost:10013
|
||||
# URL前缀(需包含context-path)
|
||||
url-prefix: /api/file
|
||||
# 腾讯云COS存储配置
|
||||
cos:
|
||||
# 是否启用COS
|
||||
enabled: false
|
||||
# 腾讯云SecretId
|
||||
secret-id: your-secret-id
|
||||
# 腾讯云SecretKey
|
||||
secret-key: your-secret-key
|
||||
# 区域,如ap-guangzhou、ap-beijing等
|
||||
region: ap-guangzhou
|
||||
# 存储桶名称
|
||||
bucket-name: your-bucket-name
|
||||
# 访问域名(可选,如果配置则使用该域名生成访问URL)
|
||||
domain: https://your-bucket-name.cos.ap-guangzhou.myqcloud.com
|
||||
# 文件前缀
|
||||
prefix: aioj
|
||||
# 预签名URL过期时间(秒)
|
||||
presigned-url-expire-seconds: 3600
|
||||
# 异步线程池配置(用于大文件哈希计算)
|
||||
async:
|
||||
# 核心线程数
|
||||
core-pool-size: 2
|
||||
# 最大线程数
|
||||
max-pool-size: 5
|
||||
# 队列容量
|
||||
queue-capacity: 100
|
||||
# 线程名前缀
|
||||
thread-name-prefix: file-async-
|
||||
|
||||
Reference in New Issue
Block a user