当前位置: 首页 > news >正文

建设网站需要营业执照小学学校网站模板

建设网站需要营业执照,小学学校网站模板,网站建设需求调研报告,梵美传媒网站是谁做的业务背景#xff1a; 在开发过程中#xff0c;我们会遇到需要对文件#xff08;单个或多个#xff09;进行压缩并下载的功能需求#xff0c;这里记录一下压缩多个文件的实现过程#xff0c;或许有更好的方式请大家补充 前端实现一个按钮调下载压缩包的接口 button…业务背景 在开发过程中我们会遇到需要对文件单个或多个进行压缩并下载的功能需求这里记录一下压缩多个文件的实现过程或许有更好的方式请大家补充 前端实现一个按钮调下载压缩包的接口 button icondownload typeprimary clickdownload下载压缩包 buttonscriptdownload () {location.href faceConfig.basePath /download? fileIds paramData.fileIds //业务参数,根据实际情况写}, /script 后端接口实现 controller控制层定义下载压缩包接口 GetMapping(download)public void download(String fileIds){readService.download(fileIds,getResponse());} 定义service服务层接口  public interface ReadService {void download(String fileIds, HttpServletResponse response); } 定义服务层接口实现类  Overridepublic void download(String fileIds, HttpServletResponse response) {String[] Ids fileIds.split(,);Map map new HashMap();Map bas64Map new HashMap();File[] file new File[Ids.length];File file1 null;OutputStream output null;BufferedOutputStream bufferedOutput null;FileInputStream inStream null;try {for (int i 0; i Ids.length; i) {// 1.获取到要压缩的文件这里是自己的业务逻辑可根据实际情况去写只要最后能拿到file就行Map paramMap new HashMap();paramMap.put(Id, Ids[i]);map certificatePrintReadMapper.getFileInfo(paramMap);bas64Map WaterMarkUtils.createStringMark(map);String base64 (String) bas64Map.get(qj);byte[] bytes decode(base64);file1 new File(Ids[i] 证书.jpg);output new FileOutputStream(file1);bufferedOutput new BufferedOutputStream(output);bufferedOutput.write(bytes);// 2。文件放到文件数组里file[i] file1;output.close();bufferedOutput.close();}// 3.创建压缩文件将文件数组进行压缩File zip new File(压缩包名字.zip);// 压缩文件zipFiles(file, zip);response.setContentType(*/*);response.addHeader(Content-Disposition, attachment;filename new String(压缩包名字.zip.getBytes(), ISO8859-1));ServletOutputStream outputStream response.getOutputStream();inStream new FileInputStream(zip);byte[] buf new byte[4096];int readLength;while (((readLength inStream.read(buf)) ! -1)) {outputStream.write(buf, 0, readLength);}inStream.close();outputStream.flush();outputStream.close();} catch (IOException e) {e.printStackTrace();} finally {if (bufferedOutput ! null) {try {bufferedOutput.close();} catch (IOException e) {e.printStackTrace();}}if (inStream ! null) {try {inStream.close();} catch (IOException e) {e.printStackTrace();}}}}//子方法压缩文件public static void zipFiles(File[] srcfile, File zipfile) {byte[] buf new byte[1024];FileInputStream in null;try {ZipOutputStream out new ZipOutputStream(new FileOutputStream(zipfile), StandardCharsets.UTF_8);//File file2 null;for (int i 0; i srcfile.length; i) {String filename srcfile[i].getName();in new FileInputStream(srcfile[i]);out.putNextEntry(new ZipEntry(filename));int len;while ((len in.read(buf)) 0) {out.write(buf, 0, len);}// out.setEncoding(GBK);out.closeEntry();in.close();System.out.println(srcfile[i].delete());}out.close();} catch (IOException e) {//e.printStackTrace();} finally {try {if (in ! null) {in.close();}} catch (IOException e) {//e.printStackTrace();}}}//子方法将Base64转成字节数组public static byte[] decode(String str) {byte[] b null;String result null;if (str ! null) {BASE64Decoder decoder new BASE64Decoder();try {b decoder.decodeBuffer(str);// result new String(b, utf-8);} catch (Exception e) {}}return b;} 这样就实现了一个将多个文件进行压缩并下载的功能啦
http://www.huolong8.cn/news/286308/

相关文章:

  • 简述网站开发的基本流程开发手机网站制作
  • 无锡市新区建设环保局网站辽宁教育网站建设费用
  • 上传引用图片 网站wordpress搜索框
  • 南京公司网站建设怎么收费长沙口碑最好网站建设公司排行榜
  • 做外汇消息面的网站地推接单网
  • 云南网站新备案制网站开发工作室策划案
  • 吴忠网站建设wordpress如何加链接
  • 西安找建网站公司企业做网站维护
  • 班级网站建设方案书泰州 做网站
  • 网站怎么制作 推广学生个人网页制作代码模板
  • 北京网站搭建公司排名wordpress 内网穿透
  • 新乡网站建设waterseo手机管理网站模板
  • 网站设计公司费用实时热榜
  • 单位网站建设目的wordpress 数据库合并
  • 在线设计平台的用户群分析搜狗 优化网站
  • 赤峰浩诚网站建设公司18款app软件免费下载百度
  • 机械产品做哪个网站网络建设解决方案专业公司
  • 网站背景怎么弄做国内学历公证的网站
  • iis如何设置服务器上网站空间大小网站建设主流语言
  • 罗湖商城网站设计推荐大型网站建设兴田德润优惠
  • 建设网站 买了域名还要什么做效果图常用的网站
  • 广州商城建站系统个人网站备案名称举例
  • 培训网站开发wordpress 指定模板
  • 济南网站建设服务建设一个企业网站一般多少钱
  • 斯皮尔网站建设wordpress文章底部
  • 商城建站流程建设工程招聘网
  • 昆明网站排名优化公司html菜鸟
  • 网站建设需要什么能力安卓手机优化大师官方下载
  • 做网站跟推广哪家公司好跨境电商平台有哪些上市公司
  • 成都网络公司网站html5网站的优点