def getbytes(self, path):
_path = self.validatepath(path)
data = io.BytesIO()
with ftp_errors(self, path):
with self._manage_ftp() as ftp:
try:
ftp.retrbinary(
str("RETR ") + _encode(_path, self.ftp.encoding),
data.write
)
except error_perm as error:
code, _ = _parse_ftp_error(error)
if code == 550:
if self.isdir(path):
raise errors.FileExpected(path)
raise
data_bytes = data.getvalue()
return data_bytes
评论列表
文章目录