aboutsummaryrefslogtreecommitdiff
path: root/paramiko/sftp_client.py
diff options
context:
space:
mode:
Diffstat (limited to 'paramiko/sftp_client.py')
-rw-r--r--paramiko/sftp_client.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/paramiko/sftp_client.py b/paramiko/sftp_client.py
index 1f11075..79a7761 100644
--- a/paramiko/sftp_client.py
+++ b/paramiko/sftp_client.py
@@ -533,7 +533,7 @@ class SFTPClient (BaseSFTP):
"""
return self._cwd
- def put(self, localpath, remotepath, callback=None):
+ def put(self, localpath, remotepath, callback=None, confirm=True):
"""
Copy a local file (C{localpath}) to the SFTP server as C{remotepath}.
Any exception raised by operations will be passed through. This
@@ -549,6 +549,10 @@ class SFTPClient (BaseSFTP):
transferred so far and the total bytes to be transferred
(since 1.7.4)
@type callback: function(int, int)
+ @param confirm: whether to do a stat() on the file afterwards to
+ confirm the file size (since 1.7.7)
+ @type confirm: bool
+
@return: an object containing attributes about the given file
(since 1.7.4)
@rtype: SFTPAttributes
@@ -574,9 +578,12 @@ class SFTPClient (BaseSFTP):
fr.close()
finally:
fl.close()
- s = self.stat(remotepath)
- if s.st_size != size:
- raise IOError('size mismatch in put! %d != %d' % (s.st_size, size))
+ if confirm:
+ s = self.stat(remotepath)
+ if s.st_size != size:
+ raise IOError('size mismatch in put! %d != %d' % (s.st_size, size))
+ else:
+ s = SFTPAttributes()
return s
def get(self, remotepath, localpath, callback=None):