title: OSError: size mismatch in put! 4628344 != 330596
body: <p>I was trying to send a file using SFTP python library <code>pysftp</code> to a remote mailbox server. But when I try to put the file I get this Error:</p>
  
  <p>I'm using python  3.7.4</p>
  
  <pre><code>Traceback (most recent call last):
   File "SFTP.py", line 54, in &lt;module&gt;
     srv.put('file.zip','file.zip')
   File "C:\Users\HP\Anaconda3\lib\site-packages\pysftp\__init__.py", line 364, in put
     confirm=confirm)
   File "C:\Users\HP\Anaconda3\lib\site-packages\paramiko\sftp_client.py", line 759, in put
     return self.putfo(fl, remotepath, file_size, callback, confirm)
   File "C:\Users\HP\Anaconda3\lib\site-packages\paramiko\sftp_client.py", line 723, in putfo
     "size mismatch in put!  {} != {}".format(s.st_size, size)
  OSError: size mismatch in put!  4628344 != 330596
  </code></pre>
  
  <p>PS:I tried with another remote server and it works perfectly.
  This is my code</p>
  
  <pre><code>import pysftp
  import os
  cnopts = pysftp.CnOpts()
  hostkeys = None
  host="host.com"
  username=username
  password=password
  
  if cnopts.hostkeys.lookup(host) == None:
      print("New host - will accept any host key")
      # Backup loaded .ssh/known_hosts file
      hostkeys = cnopts.hostkeys
      # And do not verify host key of the new host
      cnopts.hostkeys = None
  
  with pysftp.Connection(host=host, username=username, password=password, cnopts=cnopts) as sftp:        
      if hostkeys != None:
          print("Connected to new host, caching its hostkey")
          hostkeys.add(host, sftp.remote_server_key.get_name(), sftp.remote_server_key)
          hostkeys.save(pysftp.helpers.known_hosts())
  
  
  srv = pysftp.Connection(host=host, username=username,password=password)
  srv.put('file.zip','file.zip')
  </code></pre>