#1 Re: mORMot 1 » Interface based service with Delphi Android client » 2019-11-29 07:04:20

Thank you very much for your hints, that helped a lot :-).

#2 mORMot 1 » Interface based service with Delphi Android client » 2019-11-27 07:47:36

Georg
Replies: 2

Hello,

I built an interfaced based service based on the example 14 with a windows client and everything works fine.
Now I'm trying to create an android client for this service. I exchanged the mormot.pas with the corresponding crossplatform units, but I'm stuck on how to proceed.
In the class TSQLRestClientHTTP in the crossplatform units, methods like:
  FClient.ServiceDefine([IServerMethods], sicPerUser, SERVER_CONTRACT);// sicShared);
  FClient.Services['ServerMethods'].Get(ServerMethods);
are not defined.

So how do I get the interface methods on the client side? Is it necessary to change/amend the server side or is it sufficient to make changes on the client side? I searched the forum and the documentation and checked out the example 27 on crossplatform clients, but it didn't really clarify things for me.

Any help would be appreciated.

Thanks in advance,
Georg

#3 Re: mORMot 1 » Problem with GroupRights in AuthUser table when creating new User » 2019-11-07 10:32:39

Thank you very much for your help and the hint with InitializeTable.
I didn't think that such a cast would be allowed.

Best regards

#4 Re: mORMot 1 » Problem with GroupRights in AuthUser table when creating new User » 2019-11-07 10:18:23

Thanks for your answer, unfortunately, this does not work (it results in a compiler error "incompatible types" in Delphi).

AuthUser.GroupRights is of the type TSQLAuthGroup, not TID.

Best regards

#5 mORMot 1 » Problem with GroupRights in AuthUser table when creating new User » 2019-11-07 09:13:36

Georg
Replies: 4

Hello,

I used the sample 14 (interfaced based services, Project14ServerExternal) and tried to add a new user at the startup of the server like this:

function CreateUser(const ServerL: TSQLRestServer; const strLogon, strDisplay, strPassword: String): Boolean;
var AuthUser: TSQLAuthUser;
    AuthGroup: TSQLAuthGroup;
begin
  AuthGroup := TSQLAuthGroup.Create(ServerL, 'Ident=''User''');
  AuthUser := TSQLAuthUser.Create(ServerL, 'LogonName=''' + StringToUTF8(strLogon) + '''');
  try
    if Assigned(AuthUser) and (AuthUser.ID > 0) then
      Result := False
    else
    begin
      if not Assigned(AuthUser) then
        AuthUser := TSQLAuthUser.Create;
      AuthUser.LogonName := StringToUTF8(strLogon);
      AuthUser.DisplayName := StringToUTF8(strDisplay);
      AuthUser.PasswordPlain := StringToUTF8(strPassword);
      AuthUser.GroupRights := AuthGroup;
      ServerL.Add(AuthUser, True);
      Result := True;
    end;
  finally
    AuthUser.Free;
    AuthGroup.Free;
  end;
end;

I put the call to this function in the server programm directly after CreateMissingTables.
What I expected was that this would create a new user that is part of the group "User".

When I check in the sqlite database, the new user has GroupRights=49224560 in the AuthUser table, but I would have expected GroupRights=3 (since the new user should be in the "User" group with Id=3).
This new user is not able to call the interface methods, only when I change the GroupRights to 3 manually does the user account work as expected.

Thanks in advance for your help.

#6 Re: mORMot 1 » Upload and download of big files » 2016-11-23 13:05:08

Thanks for your answer. Unfortunately, I don't really know how to proceed.

ab wrote:

You can make custom download - using TServiceCustomAnswer custom record type.
If you supply STATICFILE_CONTENT_TYPE constant as output header, you can let http.sys download the file in chunks.

Can you elaborate on that? Oder maybe point me to an example or the part of the documentation where this is described?
Does this work with the TSQLHttpServer that I use in my interface-based approach?

#7 mORMot 1 » Upload and download of big files » 2016-11-22 14:59:28

Georg
Replies: 6

Hello,

I'm new to mORMot (btw, thanks for the nice talks about mORMot at EKON20 :-)) and I'm now trying to convert a datasnap based client server application to mORMot.
For client server services, I use an interface (as in sample 14 with a TSQLHttpServer).

So far this worked well. But now, I need to upload and download big files (up to 1 GB) between server and client.
I checked out the other threads concerning this topic, but I'm still not sure how to do it.

In the datasnap code, I had a download and upload method like this (FileName is the name on the server, ServerType is for getting the right path on the server):

procedure UploadFile(str: TStream; ServerType: string; FileName: string);
function DownloadFile(ServerType: string; FileName: string): TStream;

The data transfer was then done via the TStream object (with progress indicator in the client).

This approach is not possible out of the box in mORMot, I get an error because TStream cannot automatically be serialized.

I tried to do the transfer via a RawByteString object (as described in another thread here in the forum), but due to the size of the files, the memory consumption is to high.
I also read about doing this via a method based service, but I'm not sure if this can be mixed with my interface based service (I would rather like to stay with the interface based approach if possible).

The client is a delphi client, but later on it may also be a web (AJAX) client, so the solution should work in both cases.

What would be the best way to implement this upload and download with mORMmot?

Thanks in advance,
Georg

Board footer

Powered by FluxBB