You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "aru-trackunit (via GitHub)" <gi...@apache.org> on 2023/02/15 12:04:44 UTC

[GitHub] [airflow] aru-trackunit commented on pull request #29477: `GoogleDriveHook`: Add folder_id param to upload_file

aru-trackunit commented on PR #29477:
URL: https://github.com/apache/airflow/pull/29477#issuecomment-1431263957

   @shahar1 I pulled your code and only added `folder_id` assignments
   ```
       file_upload = LocalFilesystemToGoogleDriveOperator(
           task_id="uploading-file"
           gcp_conn_id="gc-conn-id",
           drive_folder="Folder A",
           folder_id="Folder_A_ID",
           local_paths=[f"/tmp/file_to_upload.csv"]
       )
   ```
   The good news is that file was uploaded to a shared drive, however path's are not matching what I meant.
   I wanted the file to be uploaded to `/Folder A/file.csv` 
   `/Folder_A_ID/Folder A/file.csv`
   
   That was the case when name of the `folder_id` was equal to `drive_folder`. But maybe I expected that because I knew what the behaviour was previously.
   
   In order to get what I wanted I had to run this:
   ```
       file_upload = LocalFilesystemToGoogleDriveOperator(
           task_id="uploading-file"
           gcp_conn_id="gc-conn-id",
           drive_folder="/",
           folder_id="Folder_A_ID",
           local_paths=[f"/tmp/file_to_upload.csv"]
       )
   ```
   
   so it solves the problem, but then logs message is quite misleading.
   
   ```
   [2023-02-15, 11:25:52 UTC] {drive.py:238} INFO - File /tmp/file_to_upload.csv uploaded to gdrive:///file_to_upload.csv.
   ```
   Would be nice to get `folder_id` real path. - Not sure if possible
   
   In case this goes forward the documentation would have to be improved & maybe rename `folder_id` to `parent_folder_id` in this case and `drive_folder` to `path`. But if someone doesn't fill `folder_id` then it gets cumbersome.
   
   When I run:
   ```
       file_upload = LocalFilesystemToGoogleDriveOperator(
           task_id="uploading-file"
           gcp_conn_id="gc-conn-id",
           drive_folder="Folder A",
           folder_id="root", #I could skip that param, but added to be clear.
           local_paths=[f"/tmp/test-file-csv.csv"]
       )
   ```
   then it's placed on the user's shared drive under `Folder A` - it's a correct behaviour
   
   @eladkal 
   But yeah! Overall it's almost there!


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