Pysftp Connection.put
already checks the size of the uploaded file. That's what the confirm=True
parameter is for, You do not need to do anything more:
whether to do a stat() on the file afterwards to confirm the file size
While you can theoretically verify the checksum with SFTPFile.check
, it won't typically work, as most SFTP servers, including the widespread OpenSSH, do not support calculating checksums. So the call will fail. You would have to resort to running some shell command to calculate the checksum. See:
Comparing MD5 of downloaded files against files on an SFTP server in Python
But it's questionable whether it is worth the effort, see:
How to perform checksums during a SFTP file transfer for data integrity?
Though these days, you should not use pysftp, as it is dead. Use Paramiko directly instead. See pysftp vs. Paramiko. See basically the same question about Paramiko: How to check if Paramiko successfully uploaded a file to an SFTP server?