首页 > 解决方案 > 尝试从 GCS 存储桶获取视频(blob)对象的元数据时出现 ValueError

问题描述

运行此 python 脚本时

storage_client = storage.Client()
bucket = storage_client.bucket('bucket_name')
blob1 = bucket.get_blob(blob)
print(blob1.name)

收到以下错误:

ValueError: <Blob: bucket-name, /videos/batch1TestingVideo1/video1.mp4, 1600346932097827> 
could not be converted to unicode

存储在桶中的所有对象都是视频文件。

如何获取存储桶中存储的视频文件的元数据。

提前致谢。

标签: pythongoogle-cloud-platformgoogle-cloud-storageblobstorebucket

解决方案


谢谢大家 我发现问题了

storage_client = storage.Client()
bucket = storage_client.bucket('bucket_name')
blob1 = bucket.get_blob(blob.name)
print(blob1.name)

而不是 blob 对象,我应该通过 blob.name 来获取该对象的元数据


推荐阅读