nginx 打zip包下载文件
1、安装 nginx mod_zip 安装模块时,注意重新指定其它已安装过的模块 ngixn需要重新编译
2、java程序 value为多个文件路径
java 代码
if (StringUtil.isEmpty(value)) {
throw new AMPException("No key found or empty file list.");
}
if (!develop) {
super.response.setContentType("application/x-download");
super.response.setHeader("X-Archive-Files", "zip");
//判断是否为火狐浏览器
if(agent.contains("Firefox")){
filename = new String(filename.getBytes("UTF-8"),"ISO-8859-1");
super.response.setHeader("Content-Disposition",String.format("attachment; filename=%s.zip", filename));
}else{
super.response.setHeader("Content-Disposition", String.format("attachment; filename=%s.zip", filename));
}
}
return new ResponseEntity<String>(value, HttpStatus.OK);
//value 包含以下三个参数,
@Data
private class DLFile {
private long size;
private String url;
private String name;
@Override
public String toString() {
return String.format("- %s %s %s\n", this.size, this.url, this.name);
}
}
php 参考 https://segmentfault.com/a/1190000000621313