#1 2022-02-25 12:06:33

florian
Member
Registered: 2021-08-22
Posts: 7

Mormot2 interface based service handle binary data cross platform

Hello,

I define a procedure in a mormot2 interface based service like this:

procedure blobTest(const input: RawBlob; out output: RawBlob); //will accept and return binary format


Is there some way to make this work with a UTF-8 encoded BASE64 format instead, for access from a java (android) client?

Offline

#2 2022-02-25 12:37:23

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Mormot2 interface based service handle binary data cross platform

Just use RawUtf8 parameters and make the Base-64 conversion on your side.

Offline

#3 2022-02-25 13:01:02

florian
Member
Registered: 2021-08-22
Posts: 7

Re: Mormot2 interface based service handle binary data cross platform

Alright. Thank you!
I would like to store the data as RawBlob in a database. Are there some functions in the mormot framework to handle base64 to RawBlob and RawBlob to Base64 conversion for storage in a TOrm class?

Offline

#4 2022-02-25 15:30:07

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Mormot2 interface based service handle binary data cross platform

Yes, you have them in mormot.core.buffers.pas even with an AVX2 very fast asm version for FPC x86_64.

See BinToBase64() and Base64ToBin() functions.

Offline

#5 2022-02-25 15:52:02

florian
Member
Registered: 2021-08-22
Posts: 7

Re: Mormot2 interface based service handle binary data cross platform

Very cool. Many thanks smile

Offline

Board footer

Powered by FluxBB