标签:https for catch 导出 ini print create boolean 文章
在工作流的一张表单里可能会有多个步骤上传附件,在用户的待办中往往会存在多条带有附件的任务,如果一一打开并且点击下载链接下载,不仅费时,而且繁琐,用户体验较差。
OA系统采用的是FastDFS做为文件服务器,FastDFS的Java客户端提供了上传、下载等功能供调用。
在我之前的文章里对此有描述,目前已有的代码有对文件的批量上传功能,但下载的参数往往是针对单个文件。比如单个文件的下载方法如下:
/** * 文件下载 * @author chao.gao * @date 2014-2-17 下午5:28:23 * @see com.gaochao.platform.components.upload.IUploadService#download(java.lang.String, * java.lang.String) * @param id * @param fileName */ @Override public void download(String id, String fileName) { InputStream in= null; FileOutputStream out = null; try { Resource[] resources = RESOLVER .getResources("classpath*:com/fx/**/META-INF/upload/*.conf"); if (resources == null || resources.length < 1) { LOGGER.error("下载文件失败,失败原因 : ", "client.conf不存在!"); } else { in = resources[0].getInputStream(); File file = new File("client.conf"); out = new FileOutputStream(file); byte[] buf = new byte[1024]; while (true) { int r = in.read(buf); if (r == -1) { break; } out.write(buf, 0, r); } ClientGlobal.init(file.getAbsolutePath()); LOGGER.info("下载中:" + "client.conf初始化成功!"); TrackerClient trackerClient = new TrackerClient(); TrackerServer trackerServer = trackerClient.getConnection(); if (trackerServer != null) { LOGGER.info("下载中:" + "成功获得均衡器"); } else { LOGGER.error("下载失败:" + "均衡器获取失败"); } StorageServer storageServer = null; StorageClient storageClient = new StorageClient(trackerServer, storageServer); // groupName and remoteFileName should exist String group_name = "group1"; AttachmentEntity aEntity = p_w_uploadDao.queryById(id); String remote_filename = aEntity.getPosition(); String[] paths = remote_filename.split("/"); FileInfo fi = storageClient.get_file_info(paths[0], remote_filename.replace(paths[0] + "/", "")); LOGGER.error("下载中..." + "得到文件信息"); HttpServletResponse response = ResponseContext .geRequestContext().getResponse(); response.reset(); response.setContentType("application/download;charset=UTF-8"); // response