dabla commented on code in PR #64465:
URL: https://github.com/apache/airflow/pull/64465#discussion_r3098289931


##########
providers/sftp/src/airflow/providers/sftp/hooks/sftp.py:
##########
@@ -789,24 +793,145 @@ def _get_value(self_val, conn_val, default=None):
         ssh_client_conn = await asyncssh.connect(**conn_config)
         return ssh_client_conn
 
-    async def list_directory(self, path: str = "") -> list[str] | None:  # 
type: ignore[return]
-        """Return a list of files on the SFTP server at the provided path."""
+    async def retrieve_file(
+        self,
+        remote_full_path: str,
+        local_full_path: str | os.PathLike[str] | IO[bytes],
+        encoding: str = "utf-8",
+        chunk_size: int = CHUNK_SIZE,
+    ) -> None:
+        """
+        Transfer the remote file to a local location asynchronously.
+
+        If local_full_path is a string or PathLike path, the file will be put 
at that location.
+        If it is a BytesIO or other binary file-like object, the file will be 
streamed into it.
+
+        :param remote_full_path: Full path to the remote file.
+        :param local_full_path: Full path to the local file or a binary 
file-like buffer.
+        :param encoding: Encoding used only as a fallback if backend returns 
text chunks (default: "utf-8").
+        :param chunk_size: Size of chunks to read at a time (default: 64KB).
+        """
+
+        def _to_bytes(chunk: str | bytes) -> bytes:
+            if isinstance(chunk, bytes):
+                return chunk
+            return chunk.encode(encoding)
+
+        async with await self._get_conn() as ssh_conn:
+            async with ssh_conn.start_sftp_client() as sftp:
+                async with sftp.open(remote_full_path, "rb") as remote_file:
+                    if isinstance(local_full_path, (str, os.PathLike)):

Review Comment:
   This suggestion is completely wrong



-- 
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]

Reply via email to