FSClient { public Long uploadFile(String fileName, InputStream inputStream, String serverType,String subFolder) { Long result = 0L; boolean flag = false; if (inputStream != null && fileName != null) { ComFSServiceConfig comFSServiceConfig = comFSRemoteService .selectComFSServiceConfigByServerType(serverType); if (comFSServiceConfig != null) { FTPClient ftpClient = connectServer(comFSServiceConfig.getFsId()); if (ftpClient != null) { try { String dateStr = subFolder; String distFolder = comFSServiceConfig.getRootDir(); distFolder = StringUtil.trimFirstAndLastChar(distFolder, '/'); String[] distDirs = distFolder.split("/"); for (String dir : distDirs) { if (!ftpClient.changeWorkingDirectory(dir)) { ftpClient.makeDirectory(dir); ftpClient.changeWorkingDirectory(dir); } } if (!ftpClient.changeWorkingDirectory(dateStr)) { ftpClient.makeDirectory(dateStr); ftpClient.changeWorkingDirectory(dateStr); } ComFSFile fsFile = new ComFSFile(); String serverFileName = System.currentTimeMillis() + "-" + fileName; fsFile.setFsId(comFSServiceConfig.getFsId()); fsFile.setFileName(fileName); fsFile.setServerFileName(serverFileName); fsFile.setFilePath(distFolder + "/" + dateStr); fsFile.setInsertedTime(new Date()); flag = ftpClient.storeFile(new String(serverFileName.getBytes("UTF-8"), "ISO-8859-1"), inputStream); if (flag) { logger.info(serverFileName + " uploads success!"); result = comFSRemoteService.insertComFSFile(fsFile); } else { logger.error(serverFileName + " uploads failed!"); } ftpClient.logout(); ftpClient.disconnect(); } catch (Exception e) { logger.error(e); } } } else { logger.info("Con't find FSServiceConfig serverType is " + serverType); } } else { logger.info("fileName or fileData is null,please double check"); } return result; }  Long uploadFile(String fileName, InputStream inputStream, String serverType,String subFolder); Long uploadFile(String fileName, InputStream inputStream, String serverType); Long uploadFile(String fileName, byte[] fileData, String serverType); Long uploadFile(File localFile, String serverType); ComFile downloadFile(Long fileId); ComFile downloadFile(final Long fsId,final String dirName,final String filePath,final String fileName); ComFSService getComFSRemoteService(); void setComFSRemoteService(ComFSService comFSRemoteService);  }
@Test public void testUploadFile() { Assert.assertTrue(uploadFile() > 0); }