【发布时间】:2021-10-05 19:24:16
【问题描述】:
在 GCP 函数中创建了一个 python 函数来修改存储中对象的元数据。部署时显示错误,错误信息如下:
Function failed on loading user code. This is likely due to a bug in the user code.
Error message: Error: please examine your function logs to see the error cause:
https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional
troubleshooting documentation can be found at
https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit
https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting
documentation.
我的功能代码如下:
from google.cloud import storage
def set_blob_metadata(bucket_name, blob_name):
"""Set a blob's metadata."""
# bucket_name = 'your-bucket-name'
# blob_name = 'your-object-name'
storage_client = storage.Client()
bucket = storage_client.bucket(lrving)
blob = bucket.get_blob(index.html)
metadata = {'Cache-Control': 'no-store'}
blob.metadata = metadata
blob.patch()
print("The metadata for the blob {} is {}".format(blob.name, blob.metadata))
如何解决这个问题?谢谢!
【问题讨论】:
标签: python-3.x function google-cloud-platform storage