[paramiko] SFTP large files
Mark Roach
mrroach at okmaybe.com
Thu Oct 5 11:33:49 PDT 2006
On Thu, Oct 05, 2006 at 12:16:55PM -0500, Gary Hines wrote:
> I'm barely past the beginner phase with Python, but I'm finding
> a need to automate some file transfers with sftp. It works great with
> smaller files, but I'm getting Memory exceeded errors when I try larger
> files. I think the following lines are the culprit:
>
> # copy file to testing
> data = file(filename,'r').read()
> sftp.open(filename,'w').write(data)
>
I haven't looked at the details of the implementation, but my first
guess would be that the convenience method: sftp.put(localpath,
remotepath) probably reads a few blocks at a time instead of trying to
read the entire file into memory (as file().read() above does).
You might want to give that a try.
-Mark
More information about the paramiko
mailing list