def copyfileobj(self, source, target, max_chunk_size=file_transfer.MAX_COPY_CHUNK_SIZE, callback=None, **kwargs): """ Copy data from file-like object `source` to file-like object `target`. """ if 'length' in kwargs: max_chunk_size = kwargs['length'] warnings.warn(("Parameter name `length` will be removed in " "ftputil 2.6, use `max_chunk_size` instead"), DeprecationWarning, stacklevel=2) file_transfer.copyfileobj(source, target, max_chunk_size, callback)
def transfer_between_ftp(source_ftp, target_ftp, source_path, target_path): """ Копирует файл между FTP соединенеиями :param FTP source_ftp: :param FTP target_ftp: :param str source_path: :param str target_path: """ source_file = file_transfer.RemoteFile(source_ftp.ftp, source_ftp.to_byte(source_path), "rb") target_file = file_transfer.RemoteFile(target_ftp, target_ftp.to_byte(target_path), "wb") source_fobj = source_file.fobj() try: target_fobj = target_file.fobj() try: file_transfer.copyfileobj(source_fobj, target_fobj) finally: target_fobj.close() finally: source_fobj.close()