Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
poc-api
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
1
Merge Requests
1
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
poc
poc-api
Commits
52a58a33
You need to sign in or sign up before continuing.
Commit
52a58a33
authored
Jan 12, 2026
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(bos): 解决文件名中文编码问题
parent
33e42427
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
3 deletions
+7
-3
SoftwareCopyRightScheduler.java
...tware_copyright/scheduler/SoftwareCopyRightScheduler.java
+1
-1
BosConfigServiceImpl.java
.../cn/com/poc/common/service/impl/BosConfigServiceImpl.java
+5
-1
ContentReportTest.java
src/test/java/cn/com/poc/expose/ContentReportTest.java
+1
-1
No files found.
src/main/java/cn/com/poc/ai_software_copyright/scheduler/SoftwareCopyRightScheduler.java
View file @
52a58a33
...
...
@@ -374,7 +374,7 @@ public class SoftwareCopyRightScheduler {
tempFile
=
File
.
createTempFile
(
UUIDUtils
.
getUUID8
(),
DOCX_EXTENSION
);
FileUtil
.
writeBytes
(
documentBytes
,
tempFile
);
try
(
FileInputStream
fileInputStream
=
new
FileInputStream
(
tempFile
))
{
return
bosConfigService
.
upload
(
fileInputStream
,
DOCX_FILE_TYPE
,
""
,
fileName
);
return
bosConfigService
.
upload
(
fileInputStream
,
DOCX_FILE_TYPE
,
""
);
}
}
finally
{
if
(
tempFile
!=
null
&&
tempFile
.
exists
())
{
...
...
src/main/java/cn/com/poc/common/service/impl/BosConfigServiceImpl.java
View file @
52a58a33
...
...
@@ -14,6 +14,7 @@ import com.baidubce.services.bos.model.ObjectMetadata;
import
com.baidubce.services.bos.model.PutObjectRequest
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.http.client.utils.DateUtils
;
import
org.apache.http.client.utils.URLEncodedUtils
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
...
...
@@ -23,6 +24,7 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Base64
;
import
java.util.Date
;
...
...
@@ -91,7 +93,9 @@ public class BosConfigServiceImpl implements BosConfigService {
meta
.
setContentType
(
contentType
);
// 设置内容被下载时的名称。
if
(
StringUtils
.
isNoneBlank
(
FILE_NAME
))
{
meta
.
setContentDisposition
(
"attachment; filename="
+
fileName
+
"."
+
fileType
);
String
downloadName
=
fileName
+
"."
+
fileType
;
String
encoded
=
URLEncoder
.
encode
(
downloadName
,
StandardCharsets
.
UTF_8
.
name
());
meta
.
setContentDisposition
(
"attachment; filename="
+
encoded
);
}
// 设置内容被下载时的编码格式。
meta
.
setContentEncoding
(
StandardCharsets
.
UTF_8
.
displayName
());
...
...
src/test/java/cn/com/poc/expose/ContentReportTest.java
View file @
52a58a33
...
...
@@ -73,7 +73,7 @@ public class ContentReportTest {
FileOutputStream
ostream
=
new
FileOutputStream
(
file
);
poifs
.
writeFilesystem
(
ostream
);
FileInputStream
fileInputStream
=
new
FileInputStream
(
file
);
String
upload
=
bosConfigService
.
upload
(
fileInputStream
,
"docx"
,
"application/msword"
,
"
111-222
"
);
String
upload
=
bosConfigService
.
upload
(
fileInputStream
,
"docx"
,
"application/msword"
,
"
中文测试
"
);
bais
.
close
();
ostream
.
close
();
poifs
.
close
();
...
...
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