如何从标头中提取文件名以创建接收到的同名文件(MQTT)
我正在使用 python-mosquitto 订阅支持文件类型上传的 MQTT 代理。 我不知道如何从标头中提取文件名以创建与发送文件同名的接收文件?
I am using python-mosquitto to subscribe to my MQTT broker which support file type uploads.
I can't figure out how to extract the file name from the header to create the received file with the same name as the sent file ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们无法回答这个问题。
MQTT 代理没有任何“文件类型上传”的概念。他们只处理消息。
MQTT (v3.x) 消息只是字节的集合,因此它将完全取决于发布消息的内容选择如何将文件名与文件内容一起编码到消息中。
MQTT v3.x 消息标头仅包含消息发布到的主题、QOS 和 1 位保留标志。
MQTT v5.0 在标头中添加了消息属性的概念,可用于存储文件名,但您再次需要询问谁发布消息,他们使用哪个键将文件名存储在属性中。
We can't answer this.
MQTT brokers don't have any concept of "file type uploads". They only work with messages.
MQTT (v3.x) messages are just a collection of bytes so it will be entirely dependent on how what ever has published the message has chosen to encode the filename into the message along with the file content.
MQTT v3.x message headers only contain the topic the message was published to, the QOS and a 1 bit retained flag.
MQTT v5.0 added the concept of message properties in the header that could be used to store a filename, but again you would need to ask who ever is publishing the message which key they used to store the filename in a property.