FTP所有操作集成成功

This commit is contained in:
2018-05-09 21:54:38 +08:00
parent 3d5a814a5c
commit f56c7ce02a
5 changed files with 51 additions and 35 deletions

View File

@@ -60,19 +60,10 @@ public class DeleteController {
tbFile.setColfileid(fileid);
TbFile resfile = fileService.findFileById(tbFile);
File filepath = new File(resfile.getColfilepath());
if (!filepath.exists()) {
log.error("删除文件失败:" + resfile.getColfilename() + "不存在!");
return false;
} else {
if (filepath.isFile()) {
return deleteFTPFile(resfile);
// return deleteFile(resfile.getColfilepath(), resfile.getColfileid());
} else {
return deleteDirectory(resfile.getColfilepath());
}
}
return deleteFTPFile(resfile);
}
@@ -132,7 +123,7 @@ public class DeleteController {
public boolean deleteFTPFile(TbFile tbFile) {
tbFile.setColfileid(tbFile.getColfileid());
String path = "/upload/" + tbFile.getCourseName() + "/" + tbFile.getWorkFolder() + "/" + tbFile.getColfilename();
String path = "/upload/" + tbFile.getCourseName() + "/" + tbFile.getWorkFolder() + "/";
FtpOperationUtil ftpOperationUtil = new FtpOperationUtil();
boolean flagExistsFile = false;
boolean flagDeleteFile = false;
@@ -146,15 +137,15 @@ public class DeleteController {
// 如果文件路径所对应的文件存在,并且是一个文件,则直接删除
if (flagExistsFile) {
System.out.println("【path】" + path);
if (flagExistsFile) {
try {
flagDeleteFile = ftpOperationUtil.deleteFile(path);
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("【flagDeleteFile】" + flagDeleteFile);
System.out.println("【path】" + path);
if (flagExistsFile) {
try {
flagDeleteFile = ftpOperationUtil.deleteFile(path + tbFile.getColfilename());
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("【flagDeleteFile】" + flagDeleteFile);
}
if (flagDeleteFile) {
fileService.deleteFileById(tbFile);
@@ -181,7 +172,7 @@ public class DeleteController {
return false;
}
} else {
log.info("删除单个文件失败:" + path + "不存在!");
log.info("删除单个文件失败:" + path + tbFile.getColfilename() + "不存在!");
return false;
}
}