From 552c202fc4cbe0ce779131bcc0ca5f5191374ef1 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 6 Nov 2024 11:22:10 +0100 Subject: [PATCH] SFTPClient::upload_file(): add remote_filename & remote_filepath arguments --- mylib/sftp.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mylib/sftp.py b/mylib/sftp.py index c7a1c46..2d2314a 100644 --- a/mylib/sftp.py +++ b/mylib/sftp.py @@ -131,12 +131,14 @@ class SFTPClient(ConfigurableObject): log.debug("Remotly open file '%s'", remote_filepath) return self.sftp_client.open(remote_filepath, mode=mode) - def upload_file(self, filepath, remote_directory=None): + def upload_file( + self, filepath, remote_filename=None, remote_directory=None, remote_filepath=None + ): """Upload a file on SFTP server""" self.connect() - remote_filepath = os.path.join( - remote_directory if remote_directory else self.initial_directory, - os.path.basename(filepath), + remote_filepath = remote_filepath or os.path.join( + remote_directory or self.initial_directory, + remote_filename or os.path.basename(filepath), ) log.debug("Upload file '%s' to '%s'", filepath, remote_filepath) if self._just_try: