1

I am working on paramiko sftp. Is there any function similar to the ftplib retrbinary function in paramiko?

My project already supports ftp and there data is stored in memory using cStringIO and then retrbinary and storebinary are used for accessing it. I have to do the same with sftp using paramiko but it does not support these functions.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
ramsavi
  • 11
  • 2

1 Answers1

1

There is no retrbinary function, because SSH treats all files as binary.

FTP on the other hand, treats files as textfiles by default, translating line endings, so a separate retrbinary was added to prevent that translation for binary files.

To quote from the SFTPClient.file() method:

The mode indicates how the file is to be opened: 'r' for reading, 'w' for writing (truncating an existing file), 'a' for appending, 'r+' for reading/writing, 'w+' for reading/writing (truncating an existing file), 'a+' for reading/appending. The python 'b' flag is ignored, since SSH treats all files as binary.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343