首页 > 解决方案 > 如何使用 python 将 firestore blob 转换为可读文本?

问题描述

我正在尝试使用 Google python 库从 Firestore 下载数据

col = fstore.client.collection_group("collection_name")
for doc in col.stream():
    print(u'{}-{} => {}'.format(doc.reference.parent.parent.parent.parent.id, doc.id, doc.to_dict()))

这是打印出来的。

grl1-!S^\x00\x00@\x08\x01\x00 \x08\x08\x00\x00\x08\x12\x00\xe0\x07\x13\x00\x00\x08\x18\x00\xe0\x07\x19\x00\x00\x08\x1c\x00\xe0\x07J\x00\xc0\x07P\x00\xe0\x07X\x00\xc0\x07\\\x00\xe0\x07^\x00\xc0\x07_\x00\xe0\x07h\x00\xc0\x07p\x00\xe0\x07\x98\x00\x00\x08\x99\x00\xe0\x07\xa4\x00\x00\x08\xbe\x00 \x08\xbf\x00\x00\x08\xc3\x00 \x08\xc5\x00\x00\x08\xc9\x00 \x08\xe2\x00@\x08\xf8\x00`\x08\n\x01\x80\x08\x1f\x01\xa0\x08/\x01\xc0\x08C\x01\xe0\x08R\x01\x00\ta\x01 \ts\x01@\t\x84\x01`\t\x93\x01\x80\t\xa4\x01\xa0\t\xb5\x01\xc0\t\xc5\x01\xe0\t\xd9\x01\x00\n\xe9\x01 \n\xff\x01@\n\x00\x02 \n\x01\x02@\n\x14\x02`\n\x16\x02@\n\x17\x02`\n1\x02\x80\nQ\x02\xa0\ni\x02\xc0\nj\x02\xa0\nk\x02\xc0\n\x86\x02\xe0\n\x9e\x02\x00\x0b\xba\x02 \x0b\xdc\x02@\x0b\xde\x02 \x0b\xdf\x02@\x0b\x04\x03`\x0b\x05\x03@\x0b\x07\x03`\x0b6\x03\x80\x0b8\x03`\x0b:\x03\x80\x0b<\x03`\x0b?\x03\x80\x0bl\x03\xa0\x0b\x9e\x03\xc0\x0b\xc6\x03\xe0\x0b\xef\x03\x00\x0c\x12\x04 \x0c+\x04@\x0c=\x04`\x0cO\x04\x80\x0cQ\x04`\x0cR\x04\x80\x0cg\x04\xa0\x0cx\x04\xc0\x0c\x85\x04\xe0\x0c\x94\x04\x00\r\x9e\x04 \r\xae\x04@\r\xbb\x04`\r\xca\x04\x80\r\xd8\x04\xa0\r\xe9\x04\xc0\r\xf8\x04\xe0\r\x0c\x05\x00\x0e\x1d\x05 \x0e.\x05@\x0e@\x05`\x0eL\x05\x80\x0eY\x05\xa0\x0ef\x05\xc0\x0et\x05\xe0\x0e\x89\x05\x00\x0f\x96\x05 \x0f\xa3\x05@\x0f\xb1\x05 \x0f\xb3\x05\x00\x0f\xb4\x05\xe0\x0e\xb5\x05\xa0\x0e\xb6\x05\x80\x0e\xb7\x05@\x0e\xb8\x05 \x0e\xb9\x05\xe0\r\xba\x05\xc0\r\xbb\x05\xa0\r\xbc\x05`\r\xbd\x05@\r\xbe\x05 \r\xbf\x05\x00\r\xc0\x05\xe0\x0c\xc1\x05\xc0\x0c\xc3\x05\xa0\x0c\xc4\x05\x80\x0c\xc5\x05`\x0c\xc7\x05@\x0c\xc8\x05 \x0c\xca\x05\x00\x0c\xcc\x05\xe0\x0b\xce\x05\xc0\x0b\xd0\x05\xa0\x0b\xd2\x05\x80\x0b

这可以被编码成相同的字符串,我可以在 Firestore UI 中看到以“Z3JsMS0hU1”开头的 blob,问题是我不知道如何从中获取任何实际值。

标签: pythongoogle-cloud-firestore

解决方案


推荐阅读