I am uploading a large file by SFTP over Jsch. During the upload process, the old file should be available, so I'm uploading to a temp file and rename it to the new file.
final String tmpName = dest + "_tmp";
channel.put(source, tmpName);
channel.rename(tmpName, dest);
The upload is ok but the renaming fails:
ERROR: Failed to upload files
4: Failure
at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2491)
at com.jcraft.jsch.ChannelSftp.rename(ChannelSftp.java:1665)
...
I can't figure out where the problem is. Please help
The target file already exists. Try deleting the existing file before renaming.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With