我正在尝试将文件上传到存储桶,解析为 json 并将其插入到 bigquery 中的表中。我收到这个错误
AttributeError: 'str' object has no attribute 'blob'
我认为这是一个依赖问题,但我不知道如何解决。
我直接在云函数 GUI 中编码。
def create_gcs(event, context):
"""Triggered by a change to a Cloud Storage bucket.
Args:
event (dict): Event payload.
context (google.cloud.functions.Context): Metadata for the event.
"""
file = event
print(f"********The file {file['name']} was created in {file['bucket']} at {event['timeCreated']}")
bucket = file['bucket']
blob = bucket.get_blob(file['name'])
data = blob.download_as_string()
table_id="tableid"
client=bigquery.Client()
client.insert_rows_json(table_id,[data])
print(blob)
暮色呼如
相关分类