pysftp put error “size mismatch in put! 0 != 14911”

i looked around for this error, but all I could really find is similar mismatch errors for python 3.3 support. I originally was getting errors when trying to use a *.txt wildcard to put all files in the localpath to the remotepath, kept getting file does not exist errors… so i finally just tried this with a single file, and got this:

size mismatch in put! 0 != 14911

Here is the code, along with python info, running linux mint 13 maya. Im really new to python and this module, and new to programming period. So dont assume i know what you are talking about….=P

Python 2.7.3 (default, Apr 20 2012, 22:39:59) [GCC 4.6.3] on linux2

import pysftp as sftp


def putjob():
    try:
        s = sftp.Connection(host='secure.sftp.site', username='username', password='password')

        remotepath='/Home/xxx24659/Upload/'
        localpath='/home/xxx24659/Local/Upload/Q0001.txt'
        s.put(localpath,remotepath)

        s.close()

    except Exception, e:
        print str(e)

putjob()

Answer

ymonad had it correct, pysftp was returning the size of the directory entry as requested.

You are correct, that pysftp does not do recursive directory copying currently. However, there is an issue for it in the tracker, so you can vote for it.

https://bitbucket.org/dundeemt/pysftp/issue/10/remote-walkdirs

or roll your own and send a pull request!

Source: stackoverflow
The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .