public void downApk(HttpServletResponse response,Apprelease apprelease) {
try {
String filename = "";
if(StringUtils.isNotEmpty(apprelease.getAndroidApp())){
filename = apprelease.getAndroidApp();
}else if(StringUtils.isNotEmpty(apprelease.getIosApp())){
filename=apprelease.getIosApp();
}
String path=appPath +"/"+filename;
File f = new File(path);
if (!f.exists()) {
response.sendError(404, "File not found!");
return;
}
filename = new String(filename.getBytes("UTF-8"), "ISO-8859-1");
BufferedInputStream br = new BufferedInputStream(new FileInputStream(f));
byte[] buf = new byte[1024];
int len = 0;
response.reset();
response.setContentType("application/x-msdownload");
response.setHeader("Content-Disposition", "attachment; filename=" + filename);
response.setContentLengthLong(f.length());
OutputStream out = response.getOutputStream();
while ((len = br.read(buf)) > 0)
out.write(buf, 0, len);
br.close();
out.close();
} catch (Exception e) {
System.err.println(e);
}
}