#1 2020-09-13 17:58:24

Onur2x
Member
Registered: 2020-09-13
Posts: 4

Many operations using Mormot

Hello there. I am a new user of mormot. In my program, I am sending files, sqlite database and sending text messages. I want to do it using Mormot. I learned a little bit and did it using the forum for sqlite and message. I can not send files. I've reviewed the demos.
1- Do I need to use a separate server for each service? (httpserver)
2- There is nowhere a comprehensive demo or sample for submitting files.

I am sorry for my English.

Offline

#2 2020-09-14 08:53:57

koraycayiroglu
Member
Registered: 2017-02-03
Posts: 55

Re: Many operations using Mormot

you should send files as rawbytestring. example:

  // sample interfaced api code

  TExampleApi = class(TInjectableObjectRest, IExampleApi)
  public
    procedure uploadfile(const rawfile: RawByteString);
  end;

implementation

procedure TExampleApi.sendfile(const rawfile: RawByteString);
begin
  FileFromString(base64toBin(rawfile), FilePath, true, FileDate);
end;

  // sample usage

  Apclient.ExampleApi.sendFile(BinToBase64(StringFromFile("C:\examplefile.png")));

Offline

#3 2020-09-14 10:53:30

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

Re: Many operations using Mormot

Base64toBin(rawfile) is not needed.
If there is a single RawByteString parameter, the content won't be JSON+base64 encoded, but sent as binary.

Check the documentation

Offline

#4 2020-09-17 09:57:24

Onur2x
Member
Registered: 2020-09-13
Posts: 4

Re: Many operations using Mormot

I am getting an error. i guess i couldn't

I am sory. I deleted code.
I want an example that can help.

Last edited by Onur2x (2020-09-17 21:15:02)

Offline

#5 2020-09-17 14:13:43

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

Re: Many operations using Mormot

Please follow the forum rules, don't put code in forum threads directly.
Especially if the code is not complete. There are missing the initialization part of your services.

So please create a gist of ready-to-reproduce sample of your problem.

Anyway, a contract error is likely to be either not the same interface, or the same service execution mode (e.g. sicShared or sicClientDriven on both sides).

Offline

Board footer

Powered by FluxBB