Base64String longer than 65535

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
User avatar
Dino
Posts: 477
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Base64String longer than 65535

Post by Dino »

Hi guys

Any idea how to handle a Base64String longer than 65535? We need to receive PDF files in a JSON restful call and they will arrive encoded as Base64String, but most likely most of them will be much longer than 64Kb. How can we handle that?

I create this simple example (a form, just for test) but my limit as you can see in this example, is the *STRING.
base64stringtest.jpg
base64stringtest.jpg (274.79 KiB) Viewed 4771 times
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientwidth(904) Clientheight(340) Componentversion(2) Left(524) Top(226)

Define Field(#PDFSTRING) Type(*STRING) Length(65535)
Define_Com Class(#XPRIM_Binary) Name(#File)

Define_Com Class(#STD_QSEL.Visual) Name(#STD_QSEL) Componentversion(1) Displayposition(4) Height(21) Left(56) Parent(#COM_OWNER) Tabposition(4) Top(24) Usepicklist(False) Width(600) Caption('PDF File with path') Labeltype(Caption)
Define_Com Class(#PRIM_LABL) Name(#Label1) Caption('Here the PDF as Base64String') Displayposition(2) Ellipses(Word) Height(129) Left(56) Parent(#COM_OWNER) Tabposition(1) Tabstop(False) Top(64) Verticalalignment(Center) Width(396) Wrapstyle(Continuous)
Define_Com Class(#STD_STRNG.Visual) Name(#STD_STRNG) Componentversion(1) Displayposition(3) Left(48) Parent(#COM_OWNER) Tabposition(2) Top(250) Width(769)
Define_Com Class(#PRIM_PHBN) Name(#ButtonStringToBin) Caption('Convert String a FILE') Displayposition(1) Left(640) Parent(#COM_OWNER) Tabposition(3) Top(64) Width(161) Height(57)
Define_Com Class(#PRIM_PHBN) Name(#ButtonFileToString64) Displayposition(5) Left(688) Parent(#COM_OWNER) Tabposition(5) Top(16) Caption('Lee Archivo y Pasa a String') Width(169)

Evtroutine Handling(#com_owner.CreateInstance)
* You can change this to whatever PDF you want to use or when running the form
#STD_QSEL := 'c:\temp\PDF32KB.pdf'
Endroutine

Evtroutine Handling(#ButtonFileToString64.Click)
#File.FromFile Path(#STD_QSEL)
* Move the file to an string 64
#PDFString := #File.AsBase64String
* Display it in the form
#Label1.Caption := #PDFSTRING
Endroutine

Evtroutine Handling(#ButtonStringToBin.Click)
* Pass the string base 64 to file
#File.FromBase64String String(#PDFSTRING)
* Just shows the location of the file... notice that it wont have the correct extension (PDF), you need to rename or copy it to use it.
#STD_STRNG := #File.AsFile
Endroutine

End_Com
User avatar
Dino
Posts: 477
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: Base64String longer than 65535

Post by Dino »

nevermind, my mistake.

I was introducing the limitation when added an string to display the result.
you dont need to do that, for example:

this simple code reads the 6MB pdf, convert to Base64String then back to a file with no problem.

#STD_QSEL := 'c:\temp\DIYStand.pdf'
#File.FromFile Path(#STD_QSEL)
#File.FromBase64String String(#File.AsBase64String)
#STD_STRNG := #File.AsFile

Thank you
Post Reply