Saving an object with a byte array in the DB

I am using an object to store workflow parameters.

This was working fine in a text field where the _response_object contained only strings

{“bywhom”:“the solicitor/instructing party”,“oldidappointments”:“B15881EE-1C70-4110-8BB0-795BF9BF6092”,“appchangereason”:“The expert has had to cancel the clinic”}

When adding a pdf into the Object though it starts to go horrible wrong. i just get a ‘null’

I have tried switching to a blob field and swtiched the blob serialisation on, but then i get a string back!

I then used iT2Be tools to try and convert what appears to be a string in the blob field that gets stored back to bytes, but the pdf I get back on reading the saved object appears to be 1/3 bigger than in the line before it is saved and blank!

This, I guess is simple, but between my reads and writes, serialisations etc something is going wrong!

Is there a correct way to store a mixed object in the DB, which field type, what serialisation and how do i read it back.

Thanks in advance.

David

first a question, how do you know how to read it back in if the object can be a string or a pdf? How do you interpreted the bytes?

I guess if you use a plain media type column (blob in db) then you can just push the bytes of the pdf or the bytes of the string (without using serializers on the column itself)

Hi David,

I think you need to encode the binary (the PDF) with base64 in your object, then serialize it to a JSON and store it in a text column.
This way it’s all text and can be de-encoded back to binary.

Hope this helps.