GH-8566: Fix SftpSession.append() for Write (#8576)

Fixes https://github.com/spring-projects/spring-integration/issues/8566

Turns out some SFTP servers are strict enough to not let to append into existing file
if we don't give in addition a `Write` open mode flag as well

**Cherry-pick to `6.0.x`**
This commit is contained in:
Artem Bilan
2023-03-20 10:56:03 -04:00
committed by GitHub
parent f2b88b4c6a
commit 1c90a60def

View File

@@ -132,7 +132,10 @@ public class SftpSession implements Session<SftpClient.DirEntry> {
public void append(InputStream inputStream, String destination) throws IOException {
synchronized (this.sftpClient) {
OutputStream outputStream =
this.sftpClient.write(destination, SftpClient.OpenMode.Create, SftpClient.OpenMode.Append);
this.sftpClient.write(destination,
SftpClient.OpenMode.Create,
SftpClient.OpenMode.Write,
SftpClient.OpenMode.Append);
FileCopyUtils.copy(inputStream, outputStream);
}
}