Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
a317a912
Commit
a317a912
authored
Dec 05, 2022
by
季圣华
Browse files
给文件上传接口增加文件名称上传的参数,非必填
parent
1171ae18
Changes
1
Hide whitespace changes
Inline
Side-by-side
jshERP-boot/src/main/java/com/jsh/erp/controller/SystemConfigController.java
View file @
a317a912
...
...
@@ -128,6 +128,7 @@ public class SystemConfigController {
try
{
String
savePath
=
""
;
String
bizPath
=
request
.
getParameter
(
"biz"
);
String
name
=
request
.
getParameter
(
"name"
);
MultipartHttpServletRequest
multipartRequest
=
(
MultipartHttpServletRequest
)
request
;
MultipartFile
file
=
multipartRequest
.
getFile
(
"file"
);
// 获取上传文件对象
if
(
StringUtil
.
isEmpty
(
bizPath
)){
...
...
@@ -136,7 +137,7 @@ public class SystemConfigController {
String
token
=
request
.
getHeader
(
"X-Access-Token"
);
Long
tenantId
=
Tools
.
getTenantIdByToken
(
token
);
bizPath
=
bizPath
+
File
.
separator
+
tenantId
;
savePath
=
this
.
uploadLocal
(
file
,
bizPath
);
savePath
=
this
.
uploadLocal
(
file
,
bizPath
,
name
);
if
(
StringUtil
.
isNotEmpty
(
savePath
)){
res
.
code
=
200
;
res
.
data
=
savePath
;
...
...
@@ -158,7 +159,7 @@ public class SystemConfigController {
* @param bizPath 自定义路径
* @return
*/
private
String
uploadLocal
(
MultipartFile
mf
,
String
bizPath
){
private
String
uploadLocal
(
MultipartFile
mf
,
String
bizPath
,
String
name
){
try
{
String
ctxPath
=
filePath
;
String
fileName
=
null
;
...
...
@@ -169,7 +170,11 @@ public class SystemConfigController {
String
orgName
=
mf
.
getOriginalFilename
();
// 获取文件名
orgName
=
FileUtils
.
getFileName
(
orgName
);
if
(
orgName
.
indexOf
(
"."
)!=-
1
){
fileName
=
orgName
.
substring
(
0
,
orgName
.
lastIndexOf
(
"."
))
+
"_"
+
System
.
currentTimeMillis
()
+
orgName
.
substring
(
orgName
.
indexOf
(
"."
));
if
(
StringUtil
.
isNotEmpty
(
name
))
{
fileName
=
name
.
substring
(
0
,
name
.
lastIndexOf
(
"."
))
+
"_"
+
System
.
currentTimeMillis
()
+
orgName
.
substring
(
orgName
.
indexOf
(
"."
));
}
else
{
fileName
=
orgName
.
substring
(
0
,
orgName
.
lastIndexOf
(
"."
))
+
"_"
+
System
.
currentTimeMillis
()
+
orgName
.
substring
(
orgName
.
indexOf
(
"."
));
}
}
else
{
fileName
=
orgName
+
"_"
+
System
.
currentTimeMillis
();
}
...
...
Write
Preview
Supports
Markdown
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