fdemiane commented on code in PR #48107:
URL: https://github.com/apache/airflow/pull/48107#discussion_r2014334320


##########
providers/google/src/airflow/providers/google/cloud/transfers/sftp_to_gcs.py:
##########
@@ -166,16 +173,26 @@ def _copy_single_object(
             destination_object,
         )
 
-        with NamedTemporaryFile("w") as tmp:
-            sftp_hook.retrieve_file(source_path, tmp.name, 
prefetch=self.sftp_prefetch)
-
-            gcs_hook.upload(
-                bucket_name=self.destination_bucket,
-                object_name=destination_object,
-                filename=tmp.name,
-                mime_type=self.mime_type,
-                gzip=self.gzip,
-            )
+        if self.use_stream:
+            dest_bucket = gcs_hook.get_conn().bucket(self.destination_bucket)
+            dest_blob = dest_bucket.blob(destination_object)
+            with dest_blob.open("wb") as write_stream:
+                sftp_hook.get_conn().getfo(

Review Comment:
   Looks good to me overall, just one NIT: one of the reasons we use hooks is 
to abstract away internal details (example: which sftp client is being used). 
Here you are directly relying on that get_conn returns a SFTPClient from the 
paramiko library. I think it would be better if you abstract away 
get_conn().getfo() into a method inside the hook. In this way also, we would 
have followed Demeter's Law.



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