Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
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
徐少华
midjourney-proxy
Commits
eee8b1dd
Commit
eee8b1dd
authored
Mar 08, 2021
by
田超
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/exportZip' into 'master'
feat: [none] 文件名支持句号 See merge request rays/pcloud-common-parent!184
parents
ac5a0b45
679d3733
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletions
+23
-1
FileUtils.java
...mmon/src/main/java/com/pcloud/common/utils/FileUtils.java
+22
-0
CompressUtils.java
.../main/java/com/pcloud/common/utils/zip/CompressUtils.java
+1
-1
No files found.
pcloud-common/src/main/java/com/pcloud/common/utils/FileUtils.java
View file @
eee8b1dd
...
...
@@ -1124,4 +1124,26 @@ public class FileUtils {
return
outStream
.
toByteArray
();
}
/**
* 格式化文件名称,过滤特殊字符(名称太长进行截断)
* 针对压缩包内文件名称, 支持.
* @param fileName
*/
public
static
String
formatName4Zip
(
String
fileName
)
{
if
(
StringUtil
.
isEmpty
(
fileName
))
{
return
null
;
}
try
{
String
regEx
=
"[*/\\\\:?\"<|>\\s+%#&=()]"
;
Pattern
p
=
Pattern
.
compile
(
regEx
);
Matcher
m
=
p
.
matcher
(
fileName
);
String
result
=
m
.
replaceAll
(
""
).
trim
();
// 文件名称过长的话,限制40个字
return
result
.
length
()
>
40
?
result
.
substring
(
0
,
40
)
:
result
;
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"【文件API】格式化文件名称.[formatName]:"
+
e
.
getMessage
(),
e
);
return
UUIDUitl
.
taskName
();
}
}
}
pcloud-common/src/main/java/com/pcloud/common/utils/zip/CompressUtils.java
View file @
eee8b1dd
...
...
@@ -188,7 +188,7 @@ public class CompressUtils {
int
idx
=
1
;
for
(
String
[]
files
:
fileUrlList
)
{
String
fileType
=
FileUtils
.
getFileType
(
files
[
1
]);
String
fileName
=
FileUtils
.
formatName
(
files
[
0
]);
String
fileName
=
FileUtils
.
formatName
4Zip
(
files
[
0
]);
String
downloadLocalPath
=
downloadPath
+
"/"
+
fileName
+
"_"
+
idx
+
"."
+
fileType
;
FileUtils
.
downloadFileFromUrl
(
files
[
1
],
downloadLocalPath
);
idx
++;
...
...
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