You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/02/03 15:01:06 UTC

[GitHub] [airflow] rafalh commented on a change in pull request #21295: Use temporary file in GCSToS3Operator

rafalh commented on a change in pull request #21295:
URL: https://github.com/apache/airflow/pull/21295#discussion_r798653064



##########
File path: airflow/providers/amazon/aws/transfers/gcs_to_s3.py
##########
@@ -164,14 +165,18 @@ def execute(self, context: 'Context') -> List[str]:
         if files:
 
             for file in files:
-                file_bytes = hook.download(object_name=file, bucket_name=self.bucket)
-
-                dest_key = self.dest_s3_key + file
-                self.log.info("Saving file to %s", dest_key)
-
-                s3_hook.load_bytes(
-                    file_bytes, key=dest_key, replace=self.replace, acl_policy=self.s3_acl_policy
-                )
+                with NamedTemporaryFile() as local_tmp_file:
+                    hook.download(object_name=file, bucket_name=self.bucket, filename=local_tmp_file.name)

Review comment:
       Changed the code to use `GCSHook.provide_file`. I didn't use it at first because in other operators i've seen `download_file` was used more frequently




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org