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
691d74b8
Commit
691d74b8
authored
Dec 16, 2021
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
下载视频
parent
f362b26e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
HttpFileHelper.java
...ain/java/com/yanzuoguang/cloud/helper/HttpFileHelper.java
+7
-1
No files found.
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/helper/HttpFileHelper.java
View file @
691d74b8
...
@@ -5,7 +5,10 @@ import com.yanzuoguang.util.helper.StringHelper;
...
@@ -5,7 +5,10 @@ import com.yanzuoguang.util.helper.StringHelper;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.io.BufferedInputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
/**
/**
...
@@ -38,8 +41,11 @@ public class HttpFileHelper extends HttpHelper {
...
@@ -38,8 +41,11 @@ public class HttpFileHelper extends HttpHelper {
// 设置下载的文件名
// 设置下载的文件名
// 2.其他浏览器attachment;filename*=utf-8'zh_cn
// 2.其他浏览器attachment;filename*=utf-8'zh_cn
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename*=utf-8'zh_cn'"
+
fileName
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename*=utf-8'zh_cn'"
+
fileName
);
response
.
setHeader
(
"fileName"
,
fileName
);
//设置输出长度
//设置输出长度
response
.
setHeader
(
"Content-Length"
,
String
.
valueOf
(
file
.
length
()));
response
.
setHeader
(
"Content-Length"
,
String
.
valueOf
(
file
.
length
()));
response
.
addHeader
(
"Access-Control-Expose-Headers"
,
"Content-Disposition"
);
response
.
addHeader
(
"Access-Control-Expose-Headers"
,
"fileName"
);
ServletOutputStream
bos
=
response
.
getOutputStream
();
ServletOutputStream
bos
=
response
.
getOutputStream
();
// 获取输入流
// 获取输入流
BufferedInputStream
bis
=
new
BufferedInputStream
(
new
FileInputStream
(
serverFilePath
));
BufferedInputStream
bis
=
new
BufferedInputStream
(
new
FileInputStream
(
serverFilePath
));
...
...
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