@RequestMapping("/downLoadZipFile")
public void downLoadZipFile(String videoAddress, String videoName, HttpServletResponse response) throws Exception {
String filePath = PlatformConstants.IMG_CONTEXT_PATH + "/" + videoAddress;
URL url = new URL(filePath);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
DataInputStream is = new DataInputStream(connection.getInputStream());
String fileName = filePath.substring(filePath.lastIndexOf("/"));
String suffix = fileName.substring(fileName.lastIndexOf("."), fileName.length());
videoName = new String(videoName.getBytes(), "ISO-8859-1");
response.reset(); // 必要地清除response中的缓存信息
response.setHeader("Content-Disposition", "attachment; filename=" + videoName + suffix);
response.setContentType("application/octet-stream");// 根据个人需要,这个是下载文件的类型
javax.servlet.ServletOutputStream out = response.getOutputStream();
byte[] content = new byte[1024];
int length = 0;
while ((length = is.read(content)) != -1) {
out.write(content, 0, length);
}
out.write(content);
out.flush();
out.close();
}
public void downLoadZipFile(String videoAddress, String videoName, HttpServletResponse response) throws Exception {
String filePath = PlatformConstants.IMG_CONTEXT_PATH + "/" + videoAddress;
URL url = new URL(filePath);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
DataInputStream is = new DataInputStream(connection.getInputStream());
String fileName = filePath.substring(filePath.lastIndexOf("/"));
String suffix = fileName.substring(fileName.lastIndexOf("."), fileName.length());
videoName = new String(videoName.getBytes(), "ISO-8859-1");
response.reset(); // 必要地清除response中的缓存信息
response.setHeader("Content-Disposition", "attachment; filename=" + videoName + suffix);
response.setContentType("application/octet-stream");// 根据个人需要,这个是下载文件的类型
javax.servlet.ServletOutputStream out = response.getOutputStream();
byte[] content = new byte[1024];
int length = 0;
while ((length = is.read(content)) != -1) {
out.write(content, 0, length);
}
out.write(content);
out.flush();
out.close();
}