引用
audit_image_src=/var/audit/upload
audit_image_zipdesc=/var/audit/desc
audit_image_zipdir=file:///D:/var/audit/desc
audit_ftp_path=ftp://root:[email protected]:21/preaudit/RECV
/** * ftp复制文件 * * @param srcPath * @param descPath * @return */ public boolean copy(String srcPath, String descPath) { FileSystemManager sfm = null; FileObject src = null; FileObject desc = null; boolean downloadResult=false; try { sfm = VFS.getManager(); src = sfm.resolveFile(srcPath); desc = sfm.resolveFile(descPath); if (src.exists()) { desc.copyFrom(src, Selectors.SELECT_FILES); close(src, sfm); close(desc, sfm); downloadResult = true; }else{ downloadResult = false; } } catch (FileSystemException e) { downloadResult = false; } finally { close(desc, sfm); close(src, sfm); } return downloadResult; } public void close(FileObject file, FileSystemManager sfm) { if (null != file) { try { file.close(); sfm.closeFileSystem(file.getFileSystem()); } catch (FileSystemException e) { logger.error("文件[" + file.toString() + "]关闭失败", e); } } }
/** * 根据批次号复制图片 * @param batchId */ @Override public void copyImgData(String batchId){ List<PreCmAttrExt> preAttrList = preCmAttrExtService.getByBatchId(batchId); for (PreCmAttrExt preCmAttrExt : preAttrList) { String fileUrl= preCmAttrExt.getUrl(); File sourceFile = new File(imageSrc+fileUrl); File tempFile = new File(imageTmp+"/"+preCmAttrExt.getBatchId().trim()+"/"+batchId+"/"+preCmAttrExt.getsId().trim()+".jpg"); try { FileUtils.copyFile(sourceFile, tempFile); logger.info("图片文件复制成功,源文件地址:"+sourceFile.getPath()+"目标文件地址:"+tempFile.getPath()); } catch (IOException e) { logger.error("图片文件复制失败,源文件地址:"+sourceFile.getPath()+"目标文件地址:"+tempFile.getPath(), e); e.printStackTrace(); } } }