|
|
@ -66,8 +66,8 @@ public class FileOptionServiceImpl implements FileOptionService { |
|
|
|
throw new BusinessException(ResultCode.FILE_NOT_EXIST); |
|
|
|
throw new BusinessException(ResultCode.FILE_NOT_EXIST); |
|
|
|
} |
|
|
|
} |
|
|
|
String fileName = fileRecord.getFileName(); |
|
|
|
String fileName = fileRecord.getFileName(); |
|
|
|
String dirPath = fileRecord.getFileUrl(); |
|
|
|
String fullPath = fileServer.getFtpRootDir()+fileRecord.getFileUrl(); |
|
|
|
FTPUtils.download(fileServer,fileName,dirPath,response); |
|
|
|
FTPUtils.download(fileServer,fileName,fullPath,response); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -82,8 +82,8 @@ public class FileOptionServiceImpl implements FileOptionService { |
|
|
|
throw new BusinessException(ResultCode.FILE_NOT_EXIST); |
|
|
|
throw new BusinessException(ResultCode.FILE_NOT_EXIST); |
|
|
|
} |
|
|
|
} |
|
|
|
String fileName = fileRecord.getFileName(); |
|
|
|
String fileName = fileRecord.getFileName(); |
|
|
|
String dirPath = fileRecord.getFileUrl(); |
|
|
|
String fullPath = fileServer.getFtpRootDir()+fileRecord.getFileUrl(); |
|
|
|
return FTPUtils.download(fileServer,fileName,dirPath); |
|
|
|
return FTPUtils.download(fileServer,fileName,fullPath); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -103,7 +103,8 @@ public class FileOptionServiceImpl implements FileOptionService { |
|
|
|
if (fileServer == null) { |
|
|
|
if (fileServer == null) { |
|
|
|
throw new BusinessException(ResultCode.FILE_SERVER_IS_NULL); |
|
|
|
throw new BusinessException(ResultCode.FILE_SERVER_IS_NULL); |
|
|
|
} |
|
|
|
} |
|
|
|
return FTPUtils.removeFile(fileServer,fileUrl,fileName); |
|
|
|
String fullPath = fileServer.getFtpRootDir()+fileUrl; |
|
|
|
|
|
|
|
return FTPUtils.removeFile(fileServer,fullPath,fileName); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -124,10 +125,11 @@ public class FileOptionServiceImpl implements FileOptionService { |
|
|
|
String newFileName = String.format("%s.%s",fileName,extension); |
|
|
|
String newFileName = String.format("%s.%s",fileName,extension); |
|
|
|
//文件存放地址
|
|
|
|
//文件存放地址
|
|
|
|
//文件在FTP服务器所在文件夹目录
|
|
|
|
//文件在FTP服务器所在文件夹目录
|
|
|
|
String dirPath = fileServer.getFtpRootDir() + String.format(IBaseEnum.getLabelByValue(fileType,FileUrlEnum.class),fileType)+System.currentTimeMillis()/1000; |
|
|
|
String dirPath = String.format(IBaseEnum.getLabelByValue(fileType,FileUrlEnum.class),fileType)+System.currentTimeMillis()/1000; |
|
|
|
|
|
|
|
String fullPath = fileServer.getFtpRootDir() +dirPath; |
|
|
|
log.info("dirPath:{}",dirPath); |
|
|
|
log.info("dirPath:{}",dirPath); |
|
|
|
try(InputStream in = file.getInputStream()) { |
|
|
|
try(InputStream in = file.getInputStream()) { |
|
|
|
boolean upload = FTPUtils.upload(fileServer, newFileName, dirPath, in); |
|
|
|
boolean upload = FTPUtils.upload(fileServer, newFileName, fullPath, in); |
|
|
|
if (!upload){ |
|
|
|
if (!upload){ |
|
|
|
throw new BusinessException(ResultCode.USER_UPLOAD_FILE_ERROR); |
|
|
|
throw new BusinessException(ResultCode.USER_UPLOAD_FILE_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|