# BLOB Payload on Custom Namespace Topic

**URL:** <https://forum.cirrus-link.com/t/blob-payload-on-custom-namespace-topic/264>\
**Category:** MQTT Modules\
**Tags:** mqtt-engine\
**Created:** [October 11, 2022, 1:42pm UTC](https://forum.cirrus-link.com/t/blob-payload-on-custom-namespace-topic/264 "2022-10-11T13:42:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andy](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Andy](https://forum.cirrus-link.com/u/Andy)\
**Post date:** [October 11, 2022, 1:42pm UTC](https://forum.cirrus-link.com/t/blob-payload-on-custom-namespace-topic/264/1 "2022-10-11T13:42:52Z")

</div>

Hi there,

MQTT Engine is set up to Subscribe to a Custom Name Space Topic and a Ignition Gateway Script is writing the message payload into a binary file.  
Everything works fine, except the content of the file looks nothing like the file of which content what was published.  
I suspect this is due to the MQTT Engine wanting to handle the payload as a Encoding Formatted String but I don’t know how to encode the payload before publishing it so that it works.  
Any help would be appreciated!

---

<div class="post-metadata">

**Author:** ![wes.johnson](https://avatars.discourse-cdn.com/v4/letter/w/f14d63/32.png) [@wes.johnson](https://forum.cirrus-link.com/u/wes.johnson)\
**Post date:** [October 11, 2022, 4:00pm UTC](https://forum.cirrus-link.com/t/blob-payload-on-custom-namespace-topic/264/2 "2022-10-11T16:00:55Z")

</div>

Could you just read the file into a String and publish the String? Something like this: [Python - Read File as String](https://www.tutorialkart.com/python/python-read-file-as-string/)

---

<div class="post-metadata">

**Author:** ![Andy](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Andy](https://forum.cirrus-link.com/u/Andy)\
**Post date:** [October 12, 2022, 7:38pm UTC](https://forum.cirrus-link.com/t/blob-payload-on-custom-namespace-topic/264/3 "2022-10-12T19:38:51Z")

</div>

Just in case anyone else is wondering how to achieve this, here is how I was able to do it in the Ignition Script Console:

```auto
#make sure that in MQTT Engine Settings you create a new Custom Namespace, then configure it like this:
#Subscriptions = 'm/Test' - change this to whatever you need
#Root Tag Folder = '' - change this to whatever you need
#Tag Name = 'imageFile' - change this to whatever you need
#JSON Payload = False
#Encoding Charset = 'ISO_8859_1'

import time

#change the send file to whatever you need
with open('C:/Users/user/Pictures/send.jpg', 'rb') as sendFile:
	sendFileData = sendFile.read()
mqttPayload = sendFileData.decode('iso8859_1')
system.cirruslink.transmission.publish('MQTT Transmission Server Name', 'm/Test', mqttPayload, 2, True)

#give the MQTT Engine some time to process the received MQTT message
time.sleep(3)

mqttQVs = system.tag.readBlocking(['[MQTT Engine]m/Test/imageFile'])
#change the received file to whatever you need
with open('C:/Users/user/Pictures/received.jpg', 'wb') as recvFile:
	recvFile.write((mqttQVs[0].value.encode('iso8859_1')))

```
