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 2021/02/11 01:20:16 UTC

[GitHub] [airflow] RNHTTR edited a comment on issue #10126: Add download function at gdrive hook

RNHTTR edited a comment on issue #10126:
URL: https://github.com/apache/airflow/issues/10126#issuecomment-777147954


   Note that the `GoogleDriveHook` inherits from the [GoogleBaseHook](https://airflow.apache.org/docs/apache-airflow-providers-google/stable/_modules/airflow/providers/google/common/hooks/base_google.html#GoogleBaseHook), which has the method `download_content_from_request`. You can use this method to write data to a file handle, e.g. a `BytesIO` object. You can then write the contents of that object to disk.
   
   Instead of adding functionality to the hook, you might want to consider creating a transfer operator, e.g. `gdrive_to_local.py` and leverage the existing functionality of `GoogleDriveHook`. You can use the `_upload_data` method in the [GoogleDriveToGCSOperator](https://github.com/RNHTTR/airflow/blob/f9d442f9a85b4b705bbe574f718034cf6bab5486/airflow/providers/google/cloud/transfers/gdrive_to_gcs.py) as an example, but instead of passing the value of the file handle to GCS, you can [write it to a file](https://stackoverflow.com/a/60450462/7004653).


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