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 :
Issue with Base64String longer than 65535 in a server module
Issue with Base64String longer than 65535 in a server module
- Attachments
-
- Screenshot 2025-02-12 120238.jpg (13.59 KiB) Viewed 29615 times
-
- Screenshot 2025-02-12 120321.jpg (38.36 KiB) Viewed 29615 times
Re: Issue with Base64String longer than 65535 in a server module
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)
#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)