问题
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( cs.host, username = 'test', password = 'test', timeout=10)
sftp = ssh.open_sftp()
res = sftp.put(filepath, destination )
?
回答1:
Use the .stat() method:
info = self.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.
回答2:
You can use this method:
lstat(self, path)
See paramiko docs
来源:https://stackoverflow.com/questions/14834442/how-to-get-size-of-remote-file