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 2020/02/26 10:15:56 UTC

[GitHub] [airflow] feluelle commented on a change in pull request #6577: [AIRFLOW-5908] Add download_file to S3 Hook

feluelle commented on a change in pull request #6577: [AIRFLOW-5908] Add download_file to S3 Hook
URL: https://github.com/apache/airflow/pull/6577#discussion_r384396483
 
 

 ##########
 File path: airflow/providers/amazon/aws/hooks/s3.py
 ##########
 @@ -652,3 +654,30 @@ def delete_objects(self, bucket, keys):
             if "Errors" in response:
                 errors_keys = [x['Key'] for x in response.get("Errors", [])]
                 raise AirflowException("Errors when deleting: {}".format(errors_keys))
+
+    @provide_bucket_name
+    @unify_bucket_name_and_key
+    def download_file(self, key: str, bucket_name: Optional[str] = None, local_path: str = '/tmp') -> str:
 
 Review comment:
   Actually if I pass `dir=None` to the `NamedTemporaryFile` constructor it will use `tempfile.gettempdir()`. 👍 
   
   In `NamedTemporaryFile`:
   `prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)`
   
   In `_sanitize_params`:
   ```
       if dir is None:
           if output_type is str:
               dir = gettempdir()
           else:
               dir = gettempdirb()
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services