Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dsk-cr20g
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
dsk-cr20g
Commits
6a0464e2
Commit
6a0464e2
authored
Jun 21, 2023
by
lixiaolei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
submit
parent
0a4e2edc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
BusinessFileController.java
...m/dsk/web/controller/business/BusinessFileController.java
+10
-1
No files found.
dsk-admin/src/main/java/com/dsk/web/controller/business/BusinessFileController.java
View file @
6a0464e2
...
...
@@ -17,6 +17,7 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -81,10 +82,18 @@ public class BusinessFileController extends BaseController {
try
{
//获取文件名
String
filename
=
file
.
getOriginalFilename
();
//TODO 校验是否上传同名文件
String
businessFileName
=
request
.
getHeader
(
"FilePath"
);
// 上传文件路径
String
filePath
=
RuoYiConfig
.
getUploadPath
()
+
businessFileName
+
"/"
;
//校验是否上传同名文件
File
newFile
=
new
File
(
filePath
);
// 获取当前目录下的文件和文件夹
File
[]
files
=
newFile
.
listFiles
();
for
(
File
allFile
:
files
)
{
if
(
filename
.
equals
(
allFile
.
getName
()))
return
error
(
"文件已存在"
);
}
// 上传并返回文件全路径
String
fileName
=
FileUploadUtils
.
upload
(
filePath
,
file
);
String
url
=
serverConfig
.
getUrl
()
+
fileName
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment