Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
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
YZG
yzg-util
Commits
70c279f8
Commit
70c279f8
authored
Nov 11, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文件处理
parent
60bb73d0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
9 deletions
+14
-9
YzgFileServiceImpl.java
...n/java/com/yanzuoguang/cloud/file/YzgFileServiceImpl.java
+14
-9
No files found.
yzg-util-file/src/main/java/com/yanzuoguang/cloud/file/YzgFileServiceImpl.java
View file @
70c279f8
...
@@ -43,14 +43,7 @@ public class YzgFileServiceImpl implements YzgFileService {
...
@@ -43,14 +43,7 @@ public class YzgFileServiceImpl implements YzgFileService {
if
(
req
.
getFile
()
==
null
||
req
.
getFile
().
length
==
0
)
{
if
(
req
.
getFile
()
==
null
||
req
.
getFile
().
length
==
0
)
{
throw
new
CodeException
(
"请上传文件"
);
throw
new
CodeException
(
"请上传文件"
);
}
}
String
folder
=
StringHelper
.
getFirst
(
req
.
getFolder
(),
"temp"
);
String
folder
=
getTempFolder
(
req
.
getFolder
());
if
(
folder
.
contains
(
".."
))
{
throw
new
CodeException
(
"文件夹不能包含两个."
);
}
if
(
folder
.
contains
(
"\\u"
))
{
throw
new
CodeException
(
"文件夹不能包含\\u"
);
}
for
(
MultipartFile
uploadFile
:
req
.
getFile
())
{
for
(
MultipartFile
uploadFile
:
req
.
getFile
())
{
// 获取上传源文件名和扩展名
// 获取上传源文件名和扩展名
String
originalFilename
=
uploadFile
.
getOriginalFilename
();
String
originalFilename
=
uploadFile
.
getOriginalFilename
();
...
@@ -91,6 +84,7 @@ public class YzgFileServiceImpl implements YzgFileService {
...
@@ -91,6 +84,7 @@ public class YzgFileServiceImpl implements YzgFileService {
*/
*/
@Override
@Override
public
void
removeTempFolder
(
String
tempFolder
)
{
public
void
removeTempFolder
(
String
tempFolder
)
{
tempFolder
=
getTempFolder
(
tempFolder
);
// 设置标记
// 设置标记
synchronized
(
cacheRemoveTempFolder
)
{
synchronized
(
cacheRemoveTempFolder
)
{
if
(
StringHelper
.
toBoolean
(
cacheRemoveTempFolder
.
get
(
tempFolder
)))
{
if
(
StringHelper
.
toBoolean
(
cacheRemoveTempFolder
.
get
(
tempFolder
)))
{
...
@@ -98,7 +92,6 @@ public class YzgFileServiceImpl implements YzgFileService {
...
@@ -98,7 +92,6 @@ public class YzgFileServiceImpl implements YzgFileService {
}
}
cacheRemoveTempFolder
.
put
(
tempFolder
,
true
);
cacheRemoveTempFolder
.
put
(
tempFolder
,
true
);
}
}
try
{
try
{
// 删除当前临时目录
// 删除当前临时目录
FileHelper
.
deleteFolder
(
tempFolder
);
FileHelper
.
deleteFolder
(
tempFolder
);
...
@@ -127,4 +120,16 @@ public class YzgFileServiceImpl implements YzgFileService {
...
@@ -127,4 +120,16 @@ public class YzgFileServiceImpl implements YzgFileService {
);
);
return
ret
;
return
ret
;
}
}
private
String
checkFolder
(
String
folderFrom
)
{
String
folder
=
StringHelper
.
getFirst
(
folderFrom
,
"temp"
);
if
(
folder
.
contains
(
".."
))
{
throw
new
CodeException
(
"文件夹不能包含两个."
);
}
if
(
folder
.
contains
(
"\\u"
))
{
throw
new
CodeException
(
"文件夹不能包含\\u"
);
}
return
folder
;
}
}
}
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