How to get size of remote file after upload file, using sftp paramiko client ? ?
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect( 'hostname', username = 'test', password = 'test', timeout=10)
sftp = ssh.open_sftp()
res = sftp.put(filepath, destination )
?
Use the .stat()
method:
info = sftp.stat(destination)
print(info.st_size)
The .stat()
method follows symlinks; if that is not desirable, use the .lstat()
method instead.
See the SFTPAttributes
class information for what attributes are available. .st_size
is the size in bytes.
You can use this method:
lstat(self, path)
See paramiko docs
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