SFTPClient::upload_file(): add remote_filename & remote_filepath arguments
Some checks failed
Run tests / tests (push) Failing after 1m26s

This commit is contained in:
Benjamin Renard 2024-11-06 11:22:10 +01:00
parent 6ccea48b23
commit 552c202fc4
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC

View file

@ -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: