Skip to main content
 首页 » 编程设计

python之使用 Airflow之Python 从本地系统将文件上传到 Google Bucket

2025年05月04日24bhlsheji

所以我在 Airflow 上运行这个操作符

from airflow.contrib.operators.file_to_gcs import FileToGoogleCloudStorageOperator 
 
gcp_operator = \ 
    FileToGoogleCloudStorageOperator( 
        task_id='gcp_task', 
        src='/Users/john/Documents/tmp', 
        dst='gs://constantine-bucket', 
        bucket='constantine-bucket', 
        google_cloud_storage_conn_id='DataScience', 
        mime_type='Folder', 
        dag=dag 
    ) 

运行时出现错误

"error": "invalid_scope", 
"error_description": "\u0026quot;https://www.googleapis.com/auth/devstorage.read_write\u0026quot; is not a valid audience string 

有没有人知道如何在 Airflow 上运行这个运算符?

请您参考如下方法:

听起来像是缺少依赖项。您应该能够使用以下方法安装 GCP Hook 和运算符:

pip install apache-airflow[gcp_api] 

有关详细信息,请参阅此页面:https://airflow.apache.org/installation.html