alexkruc commented on code in PR #26886:
URL: https://github.com/apache/airflow/pull/26886#discussion_r988827251


##########
airflow/providers/amazon/aws/hooks/s3.py:
##########
@@ -909,7 +919,17 @@ def download_file(self, key: str, bucket_name: str | None 
= None, local_path: st
                 Config=self.transfer_config,
             )
 
-        return local_tmp_file.name
+        if preserve_file_name:
+            filename_in_s3 = s3_obj.key.split('/')[-1]
+            local_folder_name = local_tmp_file.name.rsplit('/', 1)[0]
+            local_file_name = f"{local_folder_name}/{filename_in_s3}"
+
+            self.log.info("Renaming file from %s to %s", local_tmp_file.name, 
local_file_name)
+            rename(local_tmp_file.name, local_file_name)
+
+            return local_file_name

Review Comment:
   Thank you for your comment, but I've refactored the code according to 
@o-nikolas's suggestion, so now this is not relevant :( 
   
   @uranusjr  - Can you please review the new implementation? 🙏 It's a bit 
simpler, and I made sure that I'm using structured calls for paths.



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