Commit 12ede349faecfd2060b8ddf8b34f5e7bac609255
Committed by
Gitee
1 parent
247b8931
ftp的在操作之前添加一个判断超时的重试。
Showing
1 changed file
with
3 additions
and
0 deletions
yudao-framework/yudao-spring-boot-starter-file/src/main/java/cn/iocoder/yudao/framework/file/core/client/ftp/FtpFileClient.java
| ... | ... | @@ -44,6 +44,7 @@ public class FtpFileClient extends AbstractFileClient<FtpFileClientConfig> { |
| 44 | 44 | String filePath = getFilePath(path); |
| 45 | 45 | String fileName = FileUtil.getName(filePath); |
| 46 | 46 | String dir = StrUtil.removeSuffix(filePath, fileName); |
| 47 | + ftp.reconnectIfTimeout(); | |
| 47 | 48 | boolean success = ftp.upload(dir, fileName, new ByteArrayInputStream(content)); |
| 48 | 49 | if (!success) { |
| 49 | 50 | throw new FtpException(StrUtil.format("上传文件到目标目录 ({}) 失败", filePath)); |
| ... | ... | @@ -55,6 +56,7 @@ public class FtpFileClient extends AbstractFileClient<FtpFileClientConfig> { |
| 55 | 56 | @Override |
| 56 | 57 | public void delete(String path) { |
| 57 | 58 | String filePath = getFilePath(path); |
| 59 | + ftp.reconnectIfTimeout(); | |
| 58 | 60 | ftp.delFile(filePath); |
| 59 | 61 | } |
| 60 | 62 | |
| ... | ... | @@ -64,6 +66,7 @@ public class FtpFileClient extends AbstractFileClient<FtpFileClientConfig> { |
| 64 | 66 | String fileName = FileUtil.getName(filePath); |
| 65 | 67 | String dir = StrUtil.removeSuffix(filePath, fileName); |
| 66 | 68 | ByteArrayOutputStream out = new ByteArrayOutputStream(); |
| 69 | + ftp.reconnectIfTimeout(); | |
| 67 | 70 | ftp.download(dir, fileName, out); |
| 68 | 71 | return out.toByteArray(); |
| 69 | 72 | } | ... | ... |