#1 mORMot 1 » upload image » 2018-04-07 10:27:20

nostroyo
Replies: 1

Hi,

What is the best strategy to upload photo on the server? I dont want to use the sqlrawblob because i don't want the image in the db but just a path where the server actually keep my image.

I try to use an RPC with a TByteDynArray but i have wierd errors maybye it's too big for the TByteDynArray. what do you think?

#2 Re: mORMot 1 » Pb TSQLRecordMany » 2017-04-28 08:42:03

Yeah it perfectly make sense!

I don't know why i wanted to add a pivot table properties.

Thanks for the quick answer.

#3 mORMot 1 » Pb TSQLRecordMany » 2017-04-28 08:00:10

nostroyo
Replies: 2

Hi!

When i try to send an object with TSQLRecordMany properties through HTTP i've got an 406 (error execution failed (probably due to bad input parameters)).

What i've discovered is that in mormot.pas in the function JSONToObject :

 tkClass: begin
        if wasString or (P^.PropType^.ClassSQLFieldType<>sftID) then
          exit; // should have been handled above
        V := GetInteger(PropValue,err);
        if err<>0 then
          exit; // invalid value
        P^.SetOrdProp(Value,V);
      end;

In case of TSQLRecordMany the conditional expression P^.PropType^.ClassSQLFieldType <>sftID is true and the exit is executed and the function return false and this is why i've got the error.
I changed :

 if wasString or (P^.PropType^.ClassSQLFieldType<>sftID) then 

by

 if wasString or ((P^.PropType^.ClassSQLFieldType<>sftID) and (P^.PropType^.ClassSQLFieldType<>sftMany)) then 

and it's worked fine. What do you think?

Although when mORMot generate me the wrapper for crossplateform it wraps the TSQLRecordMany properties by Integer and not by TID. Is it good?

thx.

#4 Re: mORMot 1 » Recursive nested array pb » 2017-03-19 10:18:58

Do you want me to provide my test application for debug?

#5 Re: mORMot 1 » Recursive nested array pb » 2017-03-19 09:50:25

OK it's a firebird problem because if i use the standard SQLite without VirtualTableExternalRegisterAll, all works fine. I'me going to track what's the problem or switch to the in-built standard sqlite engine.

#6 Re: mORMot 1 » Recursive nested array pb » 2017-03-18 17:33:12

I use firebird

class function TDbUtility.CreateDb: TSQLRestServerDb;
var
  FProp: TSQLDBZEOSConnectionProperties;
begin
  FProp := TSQLDBZEOSConnectionProperties.Create
    (TSQLDBZEOSConnectionProperties.URI(dFirebird, '',
    'D:\Program Files\Firebird\Firebird_2_5\WOW64\fbclient.dll', False),
    'D:\delphi\FriendZone\TestYoann.fdb', 'SYSDBA', 'masterkey');
  VirtualTableExternalRegisterAll(TModelUtility.GetModel, FProp);
  Result := TSQLRestServerDB.Create(TModelUtility.GetModel, 'Test.json');
  Result.CreateMissingTables;

#7 Re: mORMot 1 » Recursive nested array pb » 2017-03-18 09:21:15

you mean by doing this :

initialization
  TJSONSerializer.RegisterObjArrayForJSON(TypeInfo(TTagDynArray), TTag);

Yes i did.

#8 Re: mORMot 1 » Recursive nested array pb » 2017-03-18 08:03:31

I notice something, the JSON response is not correct the array its a string like this : aXNwbGF5U3RyIjoiYmlrZSJ9LHsiSUQiOjg5LCJTdWJDYXQiOltdLCJEaXNwbGF5U3RyIjoiZm9vdGluZyJ9XQ==

Although if i inspect my blob as text on the DB the string is good : [{"ID":88,"SubCat":[],"DisplayStr":"bike"},{"ID":89,"SubCat":[],"DisplayStr":"footing"}]

Any suggestion?

#9 Re: mORMot 1 » Recursive nested array pb » 2017-03-17 10:55:55

Infortunatly i tried RetrieveBlobFields but its not working either.

#10 Re: mORMot 1 » Recursive nested array pb » 2017-03-17 09:31:36

OK, It's work better but with this code :

    LTag := TTag.Create;
    LTag.DisplayStr := 'Sport';
    LTag2 := TTag.Create;
    LTag2.DisplayStr := 'bike';
    FServer.Add(LTag2, True);
    LTag.DynArray('SubCat').Add(LTag2);
    LTag2 := TTag.Create;
    LTag2.DisplayStr := 'footing';
    FServer.Add(LTag2, True);
    LTag.DynArray('SubCat').Add(LTag2);
    LID := FServer.Add(LTag, True);
    FreeAndNil(LTag);
    LTag := TTag.Create(FServer, LID);
    // !subCat is empty!
    LTag2 := LTag.SubCat[1];

The SubCat array is empty, i check the blob on Db it contain the Json object. May i miss someting?

Even if i think i'm going to use a pivot table for these kind of recursive data, i want to make it work for future object wich  contains "regular" dynarray.

#11 mORMot 1 » Recursive nested array pb » 2017-03-16 16:07:04

nostroyo
Replies: 11

Hi!

I'm back to mORMot, I'm doing some test on nested array :
My business object is :

  TTag = class;
// pas d objectlist ds Mormot seulement des array
  TTagDynArray = array of TTag;

  TTag = class(TSQLRecord)
  private
    FSubCat: TTagDynArray;
    FDisplayStr: rawUTF8;
  published
    property SubCategory: TTagDynArray read FSubCat write FSubCat;
    property DisplayStr: rawUTF8 index 200 read FDisplayStr write FDisplayStr;
  end;

I try to use the ORM to store it on a DB
I create a tag sport wich has two subtags (bike and footing)

    FServer := TDbUtility.CreateDb;
    LTag := TTag.Create;
    LTag.DisplayStr := 'Sport';
    LTag2 := TTag.Create;
    LTag2.DisplayStr := 'bike';
    LTag.DynArray('SubCat').Add(LTag2);
    LTag2 := TTag.Create;
    LTag2.DisplayStr := 'footing';
    LTag.DynArray('SubCat').Add(LTag2);
    LID := FServer.Add(LTag, True);
    FreeAndNil(LTag);
    FreeAndNil(Ltag2);
    LTag := TTag.Create(FServer, LID);
    LTag2 := LTag.SubCat[1];

When i fetch the parent tag, the array Subcat[0] is good (bike) but the Subcat[1] always contain the parent tag (sport) himself.

Did i make a mistake somewhere?

#12 mORMot 1 » Adding User on server » 2015-09-04 18:38:00

nostroyo
Replies: 1

Hi,
I try to add a user on the server with this code :

  LStandardAppliUser := TSQLAuthUser.Create;
  LStandardAppliUser.LogonName := 'StdUser';
  LStandardAppliUser.PasswordPlain := 'Efficaps';
  FServer.Add(LStandardAppliUser, False);

But when i try to set a session with this user on the client side :

    FModel := TSQLModel.Create([]);
    FHttpClient := TSQLHttpClient.Create('LOCALHOST', PORT_NAME, FModel);
    FHttpClient.SetUser('StdUser','Efficaps');

I've got a forbidden error. How can i add a user even in designtime?

#14 Re: mORMot 1 » Replacing Datasnap » 2015-08-21 16:26:36

Here my class on the server side :

  
TCollDbFunc = class(TInterfacedObject, IColleaguesFunc)
  private
    FDORMConfigCtrl: TDORMCtrl;
    FLstCtrl: TListCtrl;

    function GetAdvantagesList(ASession: TSession): TAdvantages;
  public
    constructor Create;
    destructor Destroy; override;


    function GetColleagues: string;
end;

When I call GetColleagues from the client, the constructor has never be called before so my nested object FDORMConfigCtrl is nil.

#15 Re: mORMot 1 » Replacing Datasnap » 2015-08-21 14:48:17

OK i rewrote my client and server to use interface-based services, it's very powerful.

I have a problem when i want to use on the server side my object wich implement the interface, it's TServiceCalculator in the demo. never be Created, when a method is calling by the client an AV occur because the constructor never be called. I tried different Instances life time (sicSingle, sicShared...) but it doesn't change anything. Is there something i must do to solve this?

#16 mORMot 1 » Replacing Datasnap » 2015-08-19 17:03:26

nostroyo
Replies: 6

Hi!

I try to replace Datasnap (i'm afraid of what i read about it's performance and stability) with mormot. I use Datasnap only for the http communication (the SOA part). Do you have any advices for my migration?

I have just finished reading this post, where can i find the full source?

Thanks!

Board footer

Powered by FluxBB