gpt4 book ai didi

python - 避免对通过 Python SDK 发送到事件中心的数据进行 Base64 编码

转载 作者:行者123 更新时间:2023-12-03 03:42:14 25 4
gpt4 key购买 nike

我正在将一个 json 对象(在 python 中)发送到 Azure 事件中心,该对象通过事件中心的事件捕获功能路由到 Blob 存储。该文件存储在 Apache AVRO 中。当我在在线 AVRO 阅读器上上传文件时,我看到类似这样的内容.. AVRO Reader Snip

实际数据位于图像正文中。我不希望 Azure 事件中心将我的数据编码为 base64。我应该对下面的代码进行哪些更改。

    
producer = EventHubProducerClient.from_connection_string(conn_str=EVENTHUB_CONNECTION_STR, eventhub_name=eventhub)

async with producer:
dictionary_obj = {}
dictionary_obj['id'] = 1
dictionary_obj['Name'] = 'Alex'
dictionary_obj['Attr1'] = 1
MESSAGE = json.dumps(dictionary_obj)
event_data_batch = await producer.create_batch()
event_data_batch.add(EventData(MESSAGE))
await producer.send_batch(event_data_batch)
await producer.close()

最佳答案

Azure 事件中心将消息正文中的数据作为不透明字节数组进行处理。它不会在 avro write 之前对其进行编码。

关于python - 避免对通过 Python SDK 发送到事件中心的数据进行 Base64 编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70636102/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com