Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FLIPPED-AURORA
gin-vue-admin
提交
63a26dcd
G
gin-vue-admin
项目概览
FLIPPED-AURORA
/
gin-vue-admin
大约 1 年 前同步成功
通知
333
Star
18155
Fork
5506
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gin-vue-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
63a26dcd
编写于
5月 30, 2022
作者:
Sliver_Horn
提交者:
GitHub
5月 30, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1104 from aaronwmy/main
将上传目录访问路径和存储路径分开成两个配置
上级
43445049
4a6aeabe
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
18 addition
and
11 deletion
+18
-11
server/config.docker.yaml
server/config.docker.yaml
+2
-1
server/config.yaml
server/config.yaml
+2
-1
server/config/oss_local.go
server/config/oss_local.go
+2
-1
server/initialize/router.go
server/initialize/router.go
+2
-2
server/utils/upload/local.go
server/utils/upload/local.go
+6
-5
web/src/view/systemTools/system/system.vue
web/src/view/systemTools/system/system.vue
+4
-1
未找到文件。
server/config.docker.yaml
浏览文件 @
63a26dcd
...
...
@@ -104,7 +104,8 @@ db-list:
# local configuration
local
:
path
:
'
uploads/file'
path
:
'
uploads/file'
# 访问路径
store-path
:
'
uploads/file'
# 存储路径
# autocode configuration
autocode
:
...
...
server/config.yaml
浏览文件 @
63a26dcd
...
...
@@ -104,7 +104,8 @@ db-list:
# local configuration
local
:
path
:
'
uploads/file'
path
:
'
uploads/file'
# 访问路径
store-path
:
'
uploads/file'
# 存储路径
# autocode configuration
autocode
:
...
...
server/config/oss_local.go
浏览文件 @
63a26dcd
package
config
type
Local
struct
{
Path
string
`mapstructure:"path" json:"path" yaml:"path"`
// 本地文件路径
Path
string
`mapstructure:"path" json:"path" yaml:"path"`
// 本地文件访问路径
StorePath
string
`mapstructure:"store-path" json:"store-path" yaml:"store-path"`
// 本地文件存储路径
}
server/initialize/router.go
浏览文件 @
63a26dcd
...
...
@@ -27,7 +27,7 @@ func Routers() *gin.Engine {
// Router.Static("/static", "./dist/assets") // dist里面的静态资源
// Router.StaticFile("/", "./dist/index.html") // 前端网页入口页面
Router
.
StaticFS
(
global
.
GVA_CONFIG
.
Local
.
Path
,
http
.
Dir
(
global
.
GVA_CONFIG
.
Local
.
Path
))
// 为用户头像和文件提供静态地址
Router
.
StaticFS
(
global
.
GVA_CONFIG
.
Local
.
Path
,
http
.
Dir
(
global
.
GVA_CONFIG
.
Local
.
Store
Path
))
// 为用户头像和文件提供静态地址
// Router.Use(middleware.LoadTls()) // 如果需要使用https 请打开此中间件 然后前往 core/server.go 将启动模式 更变为 Router.RunTLS("端口","你的cre/pem文件","你的key文件")
global
.
GVA_LOG
.
Info
(
"use middleware logger"
)
// 跨域,如需跨域可以打开下面的注释
...
...
@@ -71,7 +71,7 @@ func Routers() *gin.Engine {
exampleRouter
.
InitFileUploadAndDownloadRouter
(
PrivateGroup
)
// 文件上传下载功能路由
// Code generated by github.com/flipped-aurora/gin-vue-admin/server Begin; DO NOT EDIT.
// Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT.
}
...
...
server/utils/upload/local.go
浏览文件 @
63a26dcd
...
...
@@ -34,13 +34,14 @@ func (*Local) UploadFile(file *multipart.FileHeader) (string, string, error) {
// 拼接新文件名
filename
:=
name
+
"_"
+
time
.
Now
()
.
Format
(
"20060102150405"
)
+
ext
// 尝试创建此路径
mkdirErr
:=
os
.
MkdirAll
(
global
.
GVA_CONFIG
.
Local
.
Path
,
os
.
ModePerm
)
mkdirErr
:=
os
.
MkdirAll
(
global
.
GVA_CONFIG
.
Local
.
Store
Path
,
os
.
ModePerm
)
if
mkdirErr
!=
nil
{
global
.
GVA_LOG
.
Error
(
"function os.MkdirAll() Filed"
,
zap
.
Any
(
"err"
,
mkdirErr
.
Error
()))
return
""
,
""
,
errors
.
New
(
"function os.MkdirAll() Filed, err:"
+
mkdirErr
.
Error
())
}
// 拼接路径和文件名
p
:=
global
.
GVA_CONFIG
.
Local
.
Path
+
"/"
+
filename
p
:=
global
.
GVA_CONFIG
.
Local
.
StorePath
+
"/"
+
filename
filepath
:=
global
.
GVA_CONFIG
.
Local
.
Path
+
"/"
+
filename
f
,
openError
:=
file
.
Open
()
// 读取文件
if
openError
!=
nil
{
...
...
@@ -62,7 +63,7 @@ func (*Local) UploadFile(file *multipart.FileHeader) (string, string, error) {
global
.
GVA_LOG
.
Error
(
"function io.Copy() Filed"
,
zap
.
Any
(
"err"
,
copyErr
.
Error
()))
return
""
,
""
,
errors
.
New
(
"function io.Copy() Filed, err:"
+
copyErr
.
Error
())
}
return
p
,
filename
,
nil
return
filepath
,
filename
,
nil
}
//@author: [piexlmax](https://github.com/piexlmax)
...
...
@@ -75,8 +76,8 @@ func (*Local) UploadFile(file *multipart.FileHeader) (string, string, error) {
//@return: error
func
(
*
Local
)
DeleteFile
(
key
string
)
error
{
p
:=
global
.
GVA_CONFIG
.
Local
.
Path
+
"/"
+
key
if
strings
.
Contains
(
p
,
global
.
GVA_CONFIG
.
Local
.
Path
)
{
p
:=
global
.
GVA_CONFIG
.
Local
.
Store
Path
+
"/"
+
key
if
strings
.
Contains
(
p
,
global
.
GVA_CONFIG
.
Local
.
Store
Path
)
{
if
err
:=
os
.
Remove
(
p
);
err
!=
nil
{
return
errors
.
New
(
"本地文件删除失败, err:"
+
err
.
Error
())
}
...
...
web/src/view/systemTools/system/system.vue
浏览文件 @
63a26dcd
...
...
@@ -189,9 +189,12 @@
<el-collapse-item
title=
"oss配置"
name=
"10"
>
<
template
v-if=
"config.system['oss-type'] === 'local'"
>
<h2>
本地文件配置
</h2>
<el-form-item
label=
"本地文件路径"
>
<el-form-item
label=
"本地文件
访问
路径"
>
<el-input
v-model=
"config.local.path"
/>
</el-form-item>
<el-form-item
label=
"本地文件存储路径"
>
<el-input
v-model=
"config.local['store-path']"
/>
</el-form-item>
</
template
>
<
template
v-if=
"config.system['oss-type'] === 'qiniu'"
>
<h2>
qiniu上传配置
</h2>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录