Size limit for Base64Decode
Hi Community,
Can I please check what the size limit for the parameter in $SYSTEM.Encryption.Base64Decode() method ?
I have a 12 page base64 encoded PDF document, which is failing when decoded. I am getting the error below:
ERROR <Ens>ErrException: <ILLEGAL VALUE>zXSDToLogical+1^%Library.Binary.1 -- logged as '-' number - @''
OBX:5 size=4233781
I tried the below from terminal, but it is not able copy the whole string for the parameter so couldn't execute it.
Set text=$SYSTEM.Encryption.Base64Decode("JVB<<TRUNCATED>>)
I am able decode the same string using notepad++ and save it as PDF. It works okay.
Thank you for your help.
Comments
The input is a string, so the max length will be your system max (which should be 3,641,144).
Assuming you're trying to retrieve the stream from a HL7 message, you will probably want to use the built in method GetFieldStreamBase64
So you could try something like:
Set tStream = ##class(%Stream.TmpBinary).%New()
Set tSC = pHL7.GetFieldStreamBase64(.tStream,"OBX:5")And then your decoded file would be in the temp stream.
(You may need to tweak this slightly depending on how you intend to then use the stream, and the correct property path of the Base64 within the HL7 message)
Thank you @Julian.Matthews7786 .
It looks like decoding is failing due to the size limit. After the temp variable reaches size greater than 3641144 I am getting the error.
Not sure if there is anyway to increase the size limit ?
I don't believe there is a way of increasing the system limit on string lengths. Even if there is, it's best to approach this by working with the data as a stream.
Otherwise you could end up in a cat and mouse game of needing to increase the length the next time you get a larger document
Thanks @Julian.Matthews7786