Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
d87343d7
提交
d87343d7
authored
11月 12, 2022
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【修复】访问数据库存储的文件,path 多层级时,无法访问的问题
上级
cdfa049c
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
16 行增加
和
9 行删除
+16
-9
FileController.java
...ao/module/infra/controller/admin/file/FileController.java
+14
-9
SecurityConfiguration.java
...nfra/framework/security/config/SecurityConfiguration.java
+2
-0
没有找到文件。
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java
浏览文件 @
d87343d7
package
cn
.
iocoder
.
yudao
.
module
.
infra
.
controller
.
admin
.
file
;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.iocoder.yudao.framework.common.pojo.CommonResult
;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.framework.common.util.servlet.ServletUtils
;
...
...
@@ -13,7 +14,6 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO;
import
cn.iocoder.yudao.module.infra.service.file.FileService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -24,6 +24,7 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.annotation.Resource
;
import
javax.annotation.security.PermitAll
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.validation.Valid
;
...
...
@@ -57,16 +58,20 @@ public class FileController {
return
success
(
true
);
}
@GetMapping
(
"/{configId}/get/
{path}
"
)
@GetMapping
(
"/{configId}/get/
**
"
)
@PermitAll
@ApiOperation
(
"下载文件"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"configId"
,
value
=
"配置编号"
,
required
=
true
,
dataTypeClass
=
Long
.
class
),
@ApiImplicitParam
(
name
=
"path"
,
value
=
"文件路径"
,
required
=
true
,
dataTypeClass
=
String
.
class
)
})
public
void
getFileContent
(
HttpServletResponse
response
,
@PathVariable
(
"configId"
)
Long
configId
,
@PathVariable
(
"path"
)
String
path
)
throws
Exception
{
@ApiImplicitParam
(
name
=
"configId"
,
value
=
"配置编号"
,
required
=
true
,
dataTypeClass
=
Long
.
class
)
public
void
getFileContent
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
(
"configId"
)
Long
configId
)
throws
Exception
{
// 获取请求的路径
String
path
=
StrUtil
.
subAfter
(
request
.
getRequestURI
(),
"/get/"
,
false
);
if
(
StrUtil
.
isEmpty
(
path
))
{
throw
new
IllegalArgumentException
(
"结尾的 path 路径必须传递"
);
}
// 读取内容
byte
[]
content
=
fileService
.
getFileContent
(
configId
,
path
);
if
(
content
==
null
)
{
log
.
warn
(
"[getFileContent][configId({}) path({}) 文件不存在]"
,
configId
,
path
);
...
...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/SecurityConfiguration.java
浏览文件 @
d87343d7
...
...
@@ -36,6 +36,8 @@ public class SecurityConfiguration {
// Spring Boot Admin Server 的安全配置
registry
.
antMatchers
(
adminSeverContextPath
).
anonymous
()
.
antMatchers
(
adminSeverContextPath
+
"/**"
).
anonymous
();
// 文件读取
registry
.
antMatchers
(
buildAdminApi
(
"/infra/file/*/get/**"
)).
permitAll
();
// TODO 芋艿:这个每个项目都需要重复配置,得捉摸有没通用的方案
// RPC 服务的安全配置
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论