【发布时间】:2018-05-02 09:15:48
【问题描述】:
我是第一次使用 mqtt 传输一些二进制文件,到目前为止我使用如下代码传输它没有问题
import paho.mqtt.client as paho
f=open("./file_name.csv.gz","rb")
filename= f.read()
f.close()
byteArray = bytearray(filename)
mqttc = paho.Client()
mqttc.will_set("/event/dropped", "Sorry, I seem to have died.")
mqttc.connect(*connection definition here*)
mqttc.publish("hello/world", byteArray )
但是,除了文件本身,还有一些我想发送的额外信息(原始文件名、创建日期等...),我找不到任何合适的方法来使用 mqtt 传输它,有没有这样做的方法还是我需要将该信息添加到消息 byteArray 本身?我该怎么做?
【问题讨论】: