我们现在要下载一个压缩包文件 并设置密码,密码统一固定
后台部分:
@Value("${drap_platform.export_password}")
private String exportPassword;
@Override
public void createZip(List<TmsTemplate> list,HttpServletResponse response,HttpServletRequest request) throws IOException {
// 数据准备
JSONObject jsonObject = new JSONObject();
String jsonStr = jsonObject.toJSONString(list, SerializerFeature.WriteDateUseDateFormat);
logger.debug("createZip json: {}" , jsonStr);
String currTime =DateUtils.dateTimeNow();
String folder = "template_" + currTime;
// 将json数组写入 template_export.json
// String dirName = tarPath + "File.separator" + folder + File.separator;
String dirName = tarPath + File.separator + folder + File.separator;
logger.debug("要操作的文件夹: {}" , dirName);
boolean exist = FileUtil.exist(dirName);
if (exist) {
FileUtil.del(dirName);
}
File jsonFile = FileUtil.file(dirName + "template_export.json"