0

I'm writing a python script that uploads a cvs file to a remote host via sftp (using pysftp). Everything appears to be working fine, but the uploaded file is always truncated to 4096 bytes. If I upload the file from the os (linux) using sftp, everything works fine. Is there a default that is set somewhere to only allow 4096 byte files?

Here's the sftp part of my code:

def sftp_file():
try:
    s = sftp.Connection(host=dropbox, username='oemreport', private_key=private_key)
    s.put(report_file, export_file)
    s.close()

except Exception, e:
    print str(e)

1 Answers1

1

If the file descriptor of "report_file" is open it won't upload the full file because it's not written entirely on disk yet.

You should close the file descriptor first.

report_file.close()
ricardgf
  • 448
  • 6
  • 11