Issue with Base64String longer than 65535 in a server module

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
DEVP
Posts: 7
Joined: Mon Mar 26, 2018 11:29 pm

Issue with Base64String longer than 65535 in a server module

Post by DEVP »

We have a server module ( JSON restful call ) to accept shipment data which includes PDF packing slip encoded in Base64String. We have no issues with PDFs which are less than 64Kb but where PDFs are greater than 64Kb, the statement high-lighted in bold/red fails:

We have verified that #iOperationRequest.ContentJsonIn.PackingSlip contains the complete base64 string data and not truncated in anyway.

How do we handle this situation? Thanks in advance.

===========================================================================================
Define_Com Class(#XPRIM_Binary) Name(#HashBytes)

#ToDocumentPath := '/SOP/'
#ToDocumentPath := #ToDocumentPath.Trim + #TBINVP + #SHIPMENTID.AsDisplayString( NumString_L ) + '.PDF' +#iOperationRequest.ContentJsonIn.PackingSlipFormat
#ToDocumentPathSave_PackingSlip := #ToDocumentPath.Trim

#HashBytes.FromBase64String String(#iOperationRequest.ContentJsonIn.PackingSlip) ErrorInfo(#ErrorInfo)

* Log Errors if can not convert from base64 string
If (*Not #ErrorInfo.OK)
#MESSAGE := " Error - Step 1 - Unable to convert from base64 string"
Return
Endif

#HashBytes.AsFile Path(#ToDocumentPath.Trim) ErrorInfo(#ErrorInfo)

* Log Errors if can not access the To directory
If (*Not #ErrorInfo.OK)
#MESSAGE := " Error - Step 2 - Unable to generate Packing Slip in SOP folder"
Return
Endif
=========================================================================================

API Definition :
Attachments
Screenshot 2025-02-12 120238.jpg
Screenshot 2025-02-12 120238.jpg (13.59 KiB) Viewed 29614 times
Screenshot 2025-02-12 120321.jpg
Screenshot 2025-02-12 120321.jpg (38.36 KiB) Viewed 29614 times
DEVP
Posts: 7
Joined: Mon Mar 26, 2018 11:29 pm

Re: Issue with Base64String longer than 65535 in a server module

Post by DEVP »

RESOLVED :) - had to use the FileStreamWriter to decode base64 value to PDF in my case i.e.

#ToDocumentPath := '/SOP/'
#ToDocumentPath := #ToDocumentPath.Trim + #TBINVP + #SHIPMENTID.AsDisplayString( NumString_L ) + '.' + #iOperationRequest.ContentJsonIn.PackingSlipFormat
#ToDocumentPathSave_PackingSlip := #ToDocumentPath.Trim
Set Com(#uoFileStreamWriter) FileAccess(ReadWrite) FileMode(OpenOrCreate) Path(#ToDocumentPath)
#uoFileStreamWriter.WriteBase64String Base64String(#iOperationRequest.ContentJsonIn.PackingSlip)
Post Reply