feat:查询文件夹属性结构接口修改,查询文件接口修改,下载文件接口修改
This commit is contained in:
parent
a17bbc343a
commit
bcb2b6b7ed
|
@ -67,7 +67,12 @@ public class FTPUtil {
|
|||
*/
|
||||
public List<LogManage> findDirectory(FTPClient ftp,List<LogManage> list,Integer parentNum,String filePath){
|
||||
try {
|
||||
ftp.changeWorkingDirectory(filePath);
|
||||
if (filePath.indexOf("/")>0){
|
||||
List<String> paths = Arrays.asList(filePath.split("/"));
|
||||
for (String path:paths) {
|
||||
ftp.changeWorkingDirectory(path);
|
||||
}
|
||||
}
|
||||
List<FTPFile> ftpFiles = Arrays.asList(ftp.listDirectories());
|
||||
if (CollectionUtils.isNotEmpty(ftpFiles)){
|
||||
int num =1;
|
||||
|
@ -77,12 +82,13 @@ public class FTPUtil {
|
|||
logManage.setName(file.getName());
|
||||
logManage.setOrderNum(num);
|
||||
logManage.setParentNum(parentNum);
|
||||
logManage.setPath(filePath+ file.getName());
|
||||
logManage.setPath(filePath +"/"+ file.getName());
|
||||
list.add(logManage);
|
||||
num++;
|
||||
// 需要加此判断。否则,ftp默认将‘项目文件所在目录之下的目录(./)’与‘项目文件所在目录向上一级目录下的目录(../)’都纳入递归,这样下去就陷入一个死循环了。需将其过滤掉。
|
||||
if (!".".equals(file.getName()) && !"..".equals(file.getName())) {
|
||||
findDirectory(ftp,list,num,file.getName());
|
||||
findDirectory(ftp,list,num,filePath +"/"+ file.getName());
|
||||
ftp.changeToParentDirectory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class LogManageController {
|
|||
logManage.setName(ftpFile.getName());
|
||||
logManage.setOrderNum(num);
|
||||
logManage.setParentNum(0);
|
||||
logManage.setPath(workPath+ "/" + ftpFile.getName());
|
||||
logManage.setPath(workPath + "/" + ftpFile.getName());
|
||||
result.add(logManage);
|
||||
num++;
|
||||
}
|
||||
|
@ -56,7 +56,8 @@ public class LogManageController {
|
|||
if (CollectionUtils.isNotEmpty(result)){
|
||||
List<LogManage> list = new LinkedList<>();
|
||||
for (LogManage logManage:result) {
|
||||
list = ftpUtil.findDirectory(ftpClient, list, logManage.getOrderNum(), logManage.getName());
|
||||
list = ftpUtil.findDirectory(ftpClient, list, logManage.getOrderNum(), workPath + "/" + logManage.getName());
|
||||
ftpClient.changeToParentDirectory();
|
||||
}
|
||||
result.addAll(list);
|
||||
}
|
||||
|
@ -127,7 +128,7 @@ public class LogManageController {
|
|||
if (ftpFile.isFile()){
|
||||
FileInfo fileInfo = new FileInfo();
|
||||
fileInfo.setFileName(ftpFile.getName());
|
||||
fileInfo.setFilePath(path+ftpFile.getName());
|
||||
fileInfo.setFilePath(path +"/"+ ftpFile.getName());
|
||||
fileInfo.setFileSize(String.format("%.2f", Double.valueOf(Double.valueOf(ftpFile.getSize())/1024)) + "KB");
|
||||
fileInfo.setFileDate(DateUtils.formatDate(ftpFile.getTimestamp(),"yyyy-MM-dd"));
|
||||
result.add(fileInfo);
|
||||
|
|
Loading…
Reference in New Issue
Block a user