如果出现问题,我需要在我的 FTP 客户端中实现恢复上传。ftp在下面的示例中是 Apache FTPClient。
public boolean upload(InputStream localFile, String remoteName, boolean createNew) {
if (StringUtils.isBlank(remoteName)) {
log.warn("Error while uploading file: localFile or remoteName is null");
return false;
}
synchronized (this) {
try {
if (createNew) {
return ftp.storeFile(remoteName, localFile);
} else {
return ftp.appendFile(remoteName, localFile); //todo is it right?
}
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
return false;
}
}
}
因此,如果ftp.storeFile崩溃(例如,并非所有字节都已发送),我如何继续使用相同的文件上传InputStream?
江户川乱折腾
相关分类