[
https://issues.apache.org/jira/browse/AIRFLOW-5703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17374326#comment-17374326
]
ASF GitHub Bot commented on AIRFLOW-5703:
-----------------------------------------
AngryHelper commented on a change in pull request #16792:
URL: https://github.com/apache/airflow/pull/16792#discussion_r663529864
##########
File path: airflow/providers/sftp/operators/sftp.py
##########
@@ -134,29 +176,68 @@ def execute(self, context: Any) -> str:
with self.ssh_hook.get_conn() as ssh_client:
sftp_client = ssh_client.open_sftp()
- if self.operation.lower() == SFTPOperation.GET:
- local_folder = os.path.dirname(self.local_filepath)
- if self.create_intermediate_dirs:
- Path(local_folder).mkdir(parents=True, exist_ok=True)
- file_msg = f"from {self.remote_filepath} to
{self.local_filepath}"
- self.log.info("Starting to transfer %s", file_msg)
- sftp_client.get(self.remote_filepath, self.local_filepath)
+ if self.local_filepath and self.remote_filepath:
+ if isinstance(self.local_filepath, list) and
isinstance(self.remote_filepath, str):
+ for file_path in self.local_filepath:
+ local_folder = os.path.dirname(file_path)
+ remote_folder =
os.path.dirname(self.remote_filepath)
+ local_file = ntpath.basename(file_path)
Review comment:
I needed to take the name of file from full path, this function was just
right for this task :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
> Airflow - SFTP Operator for multiple files
> ------------------------------------------
>
> Key: AIRFLOW-5703
> URL: https://issues.apache.org/jira/browse/AIRFLOW-5703
> Project: Apache Airflow
> Issue Type: Improvement
> Components: operators
> Affects Versions: 1.10.5
> Reporter: Mattia
> Assignee: Andrey Kucherov
> Priority: Major
>
> *AS* User
> *I WANT TO* download / upload multiple files from sftp server
> *SO THAT* i need the possibility to add a list of file instead of single one
--
This message was sent by Atlassian Jira
(v8.3.4#803005)