我正在尝试构建一个 DAG,它首先检查 Google Cloud Storage 中是否存在给定的路径/blob。blob 是包含一些 RAW 数据的那个,而不是安装在 Composer 工作器上的那个。
或者,一次性查看它是否存在并包含文件(列表> 1)会很方便,但存在已经是一件好事。
到目前为止,我尝试通过 bash 命令、google.cloud.storage 库和 gcs_hook 使用 gsutil stats 都无济于事。所有这些都为一个文件夹返回 False 我很确定存在
def check_folder(templates_dict,**kwargs):
bucket = 'bucketname'
blob_name = templates_dict['blob_name']
# Blob name is something along the lines of '2019-04-10/11/'
gcs = GoogleCloudStorageHook()
flag = gcs.exists(bucket,blob_name)
if flag:
print(flag)
return('this_is_true')
else:
print(flag)
return('this_is_not_true')
Run Code Online (Sandbox Code Playgroud)
对于给定的 blob_name,我很确定存在,我期待一个 true,但它总是返回 False。知道发生了什么吗?谢谢!