Commit 691d74b8 authored by yanzg's avatar yanzg

下载视频

parent f362b26e
...@@ -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));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment