简体   繁体   中英

How to preserve modification time when uploading a file with JSch put to SFTP server

In sftp you may use put -p to preserve the last modification timestamp. How can I do that in Java using JSch?

I use the function put(source, destination, mode) , but cannot find a value of mode similar to -p in sftp .

A current timestamp is put on the file at the destination. I want the timestamp from the source.

JSch won't do it for you. You have to explicitly update the remote timestamp after the upload using ChannelSftp.setMtime .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM