Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dc-cost-system
Overview
Overview
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
bltdc
dc-cost-system
Commits
c6ba23e7
Commit
c6ba23e7
authored
Jan 09, 2021
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
8eb189ac
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
CostFileUtil.java
...in/java/com/blt/other/module/cost/utils/CostFileUtil.java
+9
-2
No files found.
bailuntec-cost-core/src/main/java/com/blt/other/module/cost/utils/CostFileUtil.java
View file @
c6ba23e7
...
@@ -21,17 +21,25 @@ import java.io.FileOutputStream;
...
@@ -21,17 +21,25 @@ import java.io.FileOutputStream;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.util.UUID
;
import
java.util.UUID
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
/**
* 费用模块文件上传、下载工具类
* 费用模块文件上传、下载工具类
*/
*/
@Slf4j
@Slf4j
public
class
CostFileUtil
{
public
class
CostFileUtil
{
private
static
final
String
REGEX_CHINESE
=
"[\u4e00-\u9fa5]"
;
// 中文正则
public
static
String
upload
(
MultipartFile
file
,
String
filePath
)
{
public
static
String
upload
(
MultipartFile
file
,
String
filePath
)
{
// 获取文件名
// 获取文件名
String
fileName
=
file
.
getOriginalFilename
();
String
fileName
=
file
.
getOriginalFilename
();
// 去除中文
Pattern
pat
=
Pattern
.
compile
(
REGEX_CHINESE
);
Matcher
mat
=
pat
.
matcher
(
fileName
);
fileName
=
mat
.
replaceAll
(
""
);
// fileName处理
// fileName处理
fileName
=
filePath
+
UUID
.
randomUUID
()
+
"&"
+
fileName
;
fileName
=
filePath
+
UUID
.
randomUUID
()
+
"&"
+
fileName
;
...
@@ -43,8 +51,7 @@ public class CostFileUtil {
...
@@ -43,8 +51,7 @@ public class CostFileUtil {
}
}
try
{
try
{
file
.
transferTo
(
dest
);
file
.
transferTo
(
dest
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
ignored
)
{
// logger.error("affirmFile 发生错误",e);
}
}
return
fileName
;
return
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