#51 mORMot 1 » mormot2 _ObjFast AV Exception with array of const params » 2021-05-14 21:12:06

keinn
Replies: 3

function _ObjFast(const NameValuePairs: array of const): variant; overload;

eg:_ObjFast(['UserInfo',aUserRecObj,'Account',aAdminAccountrecObj]);

same code works fine in momrot 1.18

env: delphi rad 10.4.2

#52 Re: mORMot 1 » can ServiceMethodRegisterPublishedMethods support prefix contain "/" » 2021-04-28 14:35:53

sakura wrote:

Works like a charm <3

  ServiceManagerApp := TMypServiceManagerApplication.Create;
  ServiceManagerApp.Start(RestServer, TypeInfo(IMypServiceManagerApplication));
  RestServer.ServiceMethodRegisterPublishedMethods('svc_', ServiceManagerApp);

and the App-Class has methods like list_session and may now be called as domain/root/svc/list/session :-)


your situation is too add one more level suburl to the mvc app above the TMVCRunOnRestServer.Create(Self,nil,'svc');
your case is to rewrite the list_session method to /list/session

#53 Re: mORMot 1 » can ServiceMethodRegisterPublishedMethods support prefix contain "/" » 2021-04-28 14:31:32

still get me wrong.
i mean TMVCApplication  alreay have this feture , but any regular class registerd by RestServer.ServiceMethodRegisterPublishedMethods('some') dose not .
eg:

type 
    TMyDemoClass = class
    published 
        procedure list(Ctxt:TSQLRestServerURIContext);
    end;
var
  _demo:TMyDemoClass ;

begin
... rest root eg :root
RestServer.ServiceMethodRegisterPublishedMethods('demo', _demo);
end;

then i need to access the list method by http://domain/root/demo/list
but with current mormot implemention , it only can be accessed by http://domain/root/demolist

#54 Re: mORMot 1 » can ServiceMethodRegisterPublishedMethods support prefix contain "/" » 2021-04-28 13:25:33

my point is to group all method with one Prefix.
this is not to say i need to register a method with / slash or _ underline

#55 Re: mORMot 1 » can ServiceMethodRegisterPublishedMethods support prefix contain "/" » 2021-04-28 13:18:09

why TMVCApplication can register a prefix like "blog" and then can access it with "root/blog/default" ?  i mean, why this feture can not be used in ServiceMethodRegisterPublishedMethods ? any class with its published methods registed with ServiceMethodRegisterPublishedMethods with prefix ,eg "test" ,why we can not access it use "root/test/*" but "root/test*"?

#56 Re: mORMot 1 » FormatUtf8 in core.json and core.text conflit » 2021-04-28 13:10:29

i'd like to use

xx:=formatUtf8('abc%',[i])

but if the mormot.core.json and mormot.core.text both imported in the unit , u can't do so.  it can NOT be compiled .
i had to remove the mormot.core.json use from the unit.

#57 mORMot 1 » FormatUtf8 in core.json and core.text conflit » 2021-04-28 03:07:10

keinn
Replies: 4

when both core.json and core.text in the uses cluase, compiler can not find the right FormatUtf8 func

function FormatUtf8(const Format: RawUtf8; const Args: array of const): RawUtf8; overload;

#58 mORMot 1 » can ServiceMethodRegisterPublishedMethods support prefix contain "/" » 2021-04-28 02:53:17

keinn
Replies: 9

if it does ,the the uri will be more friendly
eg: domain/root
      domain/root/admin/*
      domain/root/api/*

i know the interface based service can do this ,but some times ,the method based service can be more flexable

#59 mORMot 1 » why is the orm part coupped with restserver? » 2021-04-28 02:39:32

keinn
Replies: 2

is there a way to use the orm without restserver or restclient or any rest*?
just wanna to use the orm direct

#61 mORMot 1 » mOMRot2 test fronzen dead » 2021-04-14 16:31:29

keinn
Replies: 9

mOMRot2 test fronzen dead 
after showing this :Ini files: 7,028 assertions passed

if remove "TTestCoreProcess" from then it fronzen after "Url decoding: 1,101 assertions passed"

env: delphi 10.4.1 windows 10 ltsc win32 debug mode

#62 Re: mORMot 1 » Load Balancing and Session Persistence » 2021-02-18 20:53:37

First call --> Server A
Second call --> Server B (requires root/auth login to get new session signature)
Third call --> Server A (session signature was changed above, so call is now rejected from server A)
---------------------------
this is why Redis become popular. a distributed session.

#63 Re: mORMot 1 » JSONToObject seems to change the json content » 2021-02-15 19:31:01

thanks for the quick reply .
so , if i DONT need to reuse the json, there is no need to call UniqueRawUtf8,
just
vObj :=TMyObject(JSONToNewObject(Pointor(vJson),vObjValid,[j2oIgnoreUnknownProperty]));
will be ok ? am i right?

#64 mORMot 1 » JSONToObject seems to change the json content » 2021-02-15 18:18:53

keinn
Replies: 3

i test JSONToObject function ,it works , but seems to change the json content.
i want to reuse the json content ,

follow the Documentation's guide ,
i make a local copy use @vJson[1] or UniqueRawUTF8
but after JSONToObject ,i write the vJson variable content to a memo , it only contains "classname"

var
  vJson:rawutf8;
  vJsonP:PUTF8Char;
begin

    vJsonP :=UniqueRawUTF8(vJson);//@vJson[1];
    vObj :=TMyObject(JSONToNewObject(vJsonP,vObjValid,[j2oIgnoreUnknownProperty]));
    memo1.text:=vJson; //<--here it only output "classname" not the whole json content

end;

seems local copy did not work

#65 mORMot 1 » functional suggestion :a MultiReadExclusiveWrite lock is need » 2021-02-12 16:02:36

keinn
Replies: 3

may be ,we need a MultiReadExclusiveWrite / MultiReadSingleWrite kind of lock in mormot code base.
like Delphi 10.4 TLightweightMREW wrapper or TSpinLock.
or like this repo:https://github.com/BeRo1985/pasmp

#66 mORMot 1 » Sqlite db created by mORMot Framework can Not be operated by 3rd tools » 2020-01-16 09:34:37

keinn
Replies: 8

Database created by mORMot Framework can Not be operated by 3rd tools
like  Navicat

take Sqlite3\sample\ 30 - MVC Server for demo,

navicat can open and do select Query operation

but write operation like Insert will trigger an error:

no such collation sequence: SYSTEMNOCASE

#67 mORMot 1 » latest soruce syncommons.pas bug report » 2019-12-13 11:27:36

keinn
Replies: 1

line 26551 to line 26561 can not compile
prod := SysUtils.Trim(ReadString('SystemBiosVersion'));

env:windows 10 (not virtual machine) delphi 10.3.2

#68 mORMot 1 » Feture request:TSQLRestServer need public property to work with JWT » 2019-12-13 11:21:05

keinn
Replies: 0

I'd like to implement ByPassAuthentication when use JWT authentication ,
so i  create my own ServicesRouting class and override the AuthenticationCheck(jwt: TJWTAbstract) procedure,

but the fPublishedMethod and fIPWhiteJWT is not accessable ,
may i suggest add two property'PublishedMethod' and 'IPWhiteJWT' to the TSQLRestServer class?

#69 Re: mORMot 1 » BugReport:JWTForUnauthenticatedRequest not working » 2019-12-03 16:47:28

Well, got it now, we should disable the Authentication on RestServer Creation first..

#70 mORMot 1 » BugReport:JWTForUnauthenticatedRequest not working » 2019-12-03 16:32:56

keinn
Replies: 1

Just Asigned a TJWTHS256 instance to the RestServer.JWTForUnauthenticatedRequest property,
then set the client SessionHttpHeader :Authorization: Bearer <Token>

then call any method or interface based service that need auth ,you will fail.

problem is that :

JWTForUnauthenticatedRequest not working since procedure TSQLRestServer.URI  security handling logic bug:
in mOMRot.pas:

      // 2. handle security
      if (rsoSecureConnectionRequired in fOptions) and
         (Ctxt.MethodIndex<>fPublishedMethodTimestampIndex) and
         not (llfSecured in Call.LowLevelFlags) then
        Ctxt.AuthenticationFailed(afSecureConnectionRequired) else
      if not Ctxt.Authenticate then
        Ctxt.AuthenticationFailed(afInvalidSignature) else
      if (Ctxt.Service<>nil) and
          not (reService in Call.RestAccessRights^.AllowRemoteExecute) then
        if (rsoRedirectForbiddenToAuth in Options) and (Ctxt.ClientKind=ckAjax) then
          Ctxt.Redirect(Model.Root+'/auth') else
          Ctxt.AuthenticationFailed(afRemoteServiceExecutionNotAllowed) else
      if (Ctxt.Session<>CONST_AUTHENTICATION_NOT_USED) or
         (fJWTForUnauthenticatedRequest=nil) or
         (Ctxt.MethodIndex=fPublishedMethodTimestampIndex) or
         ((llfSecured in Call.LowLevelFlags) and
          not (llfHttps in Call.LowLevelFlags)) or // HTTPS does not authenticate
         Ctxt.AuthenticationCheck(fJWTForUnauthenticatedRequest) then

line 42740 42741 always get executed if not authed

if not Ctxt.Authenticate then
        Ctxt.AuthenticationFailed(afInvalidSignature)

so fJWTForUnauthenticatedRequest never get a chance .

or i am doing it wrong?

#71 Re: mORMot 1 » MVC of the framework design is a little Imperfect » 2019-10-31 08:34:52

pvn0 wrote:
keinn wrote:

i know,i know ,  u can make AJAX request to the RestServer (not to the mvc application),

but this approach will need to deal with the rest auth, while MVC application is based on Cookie.

You don't need to deal with rest auth, you can disable/ignore it and deal with cookies directly.

you mean process Cookie head(Read/Write) in the Ctxt Context within the method based service or in the ServiceContext within the interface based service?

this can do it , and i know it , reason i post this thread is hope mORMot MVC will be more powerful and do not rely on other parts of the framework:

lets say :

mORMotMVC is more suitable to deal with cookie\Session ,while Rest Service is not so direct . and also , it is not in the MVC subRoot

again within the mORMotMVC , if we can use the Service ability directly(do not need view) in the TMVCApplication , it will be perfect

for now ,  mORMot MVC have some problem :
1、the methodname/json/ can return json data , but it can NOT take param(like json format) send by POST ,just GET work for now
2、every TMVCApplication view method need a view template, while some processing like :login/logout just need process params(by get/post) , they do NOT need view template

#72 mORMot 1 » MVC of the framework design is a little Imperfect » 2019-10-31 03:44:16

keinn
Replies: 3

Thanks ab for the great mORMot framework, it helps me a lot.

i use the framework SOA、ORM  a lot .

now i need to build a web site. i guess at somepoint , we all need a website.

i found a little imperfect of MVC:

when you just need to show some pages,
just write you view template and define some interface , it works fine, same as Sample 30--MVC Server.

but, when you need to use Ajax in pages to Post data to or Get data from  the mvc server, it CAN NOT be done.

i mean , when you need to do AJAX request from the MVC application, there the NO WAY to return json data from the mvc application(interface)

i know,i know ,  u can make AJAX request to the RestServer (not to the mvc application),

but this approach will need to deal with the rest auth, while MVC application is based on Cookie.

for example:
when user need to login to the Web(not the RestSerrver), since our MVC application can not return custom json format (which ajax need),
we loose the ablity to interact with user  before or after the login.

or  , some page need use Ajax request data only after user login (again, web cookie, not the restserver auth)

so, if mvc application return JSON data will solve all that .(not the methodname/json approach, it is still for view context)

#73 Re: mORMot 1 » Batch Insert and Duplicates » 2019-10-15 15:00:36

similar question here:
when doing such Batch Insert (already checked duplicates), or Single Insert many times (eg: insert 1000 rows of data ),
we need to hnow if the data already exsist in DB,
if we use

TSQLRecord*.Create(aRest,'id=?',[i])

  to check first ,the insert process will be very very slow, the already exist data may or maynot need update...

#74 mORMot 1 » BugReport TTextWriter.RegisterCustomJSONSerializerSetOptions » 2019-08-27 21:07:19

keinn
Replies: 1

line 51791 of SynCommons.pas:this line:

if not RegisterCustomJSONSerializerSetOptions(aTypeInfo[XXXXX],aOptions) then

Missing  the "aAddIfNotExisting" parameter cause the register of array of aTypeInfo failing.

also:i use aTypeInfo[XXXXX] ,xxxx replace i in code above because when use i in this post ,i can NOT post.

#75 Re: mORMot 1 » How to Encrypt/Decrypt with AESECB? » 2019-03-15 01:25:20

i know that now, the key also should uses some digest method to generate

#76 Re: mORMot 1 » How to Encrypt/Decrypt with AESECB? » 2019-03-15 01:12:10

var
  ret:rawbytestring;
  display:rawutf8;
begin
aes:=TAESECB.Create('123',128);
try
  ret :=aes.EncryptPKCS7('mORMot is awesome!');
  display :=BinToHex(ret);
finally
  aes.free;
end;
end;

here the display result is 76D7EC0CD8E8EACA15F8214126A62D3A7C503EB0820B52233986FF917554669C
it is wrong.
when use 128 KeySize , the result should be 1d35c8513d106079e66c1f13a0e57eb5d96f97231f345b07bd42ae6d9dd02694

#77 mORMot 1 » How to Encrypt/Decrypt with AESECB? » 2019-03-13 19:10:54

keinn
Replies: 7

input string data:"mORMot is awesome!", password is "123"

the result AESECB with pkcs5padding hex result should be :
"1d35c8513d106079e66c1f13a0e57eb5d96f97231f345b07bd42ae6d9dd02694"

is there some Decrypt wrapper function like :
function DecryptAesEcbFromHexString(const HexStr,Password:RawUtf8):RawUTF8;

or Encrpyt string to Hex string like:
function AesEcbEncryptAsHex(const Str,Password:RawUtf8):RawUTF8;

can u show some pieces of code please?
thank you very much .

#78 Re: mORMot 1 » Synopse Crc32 checksum result different from other language » 2019-02-22 13:19:55

Yes~~i just find about SynZip.pas ~
thank you for the lovely and also fastest reply ~

#79 mORMot 1 » Synopse Crc32 checksum result different from other language » 2019-02-22 08:42:15

keinn
Replies: 2

for example ,
hex:=SynCommons.crc32cUTF8ToHex('1');

here the result is '90F599E3'

it is diff from the widely used online service
https://www.lammertbies.nl/comm/info/cr … ation.html
and other online calculation services

it should be '83DCEFB7'

#80 mORMot 1 » SynCrypto AES encrytion results seems wrong » 2019-02-18 19:26:18

keinn
Replies: 1

I use serval online enc/dec services to check the AESECB encryption/decryption result ,
it seems that our SynCrypto TAESECB mode can not get any result same with the online services.

what is your result when do such enc/dec with TAESECB?
the utf8 string key is '123456'
utf8String Data is 'ABC'
All online services results:
PKCS7padding, keysize 256 : h3ivt+HEEOkunT75PoB199xf3tD1LRO/p1/l6Tdrg6I=
PKCS7padding, keysize 128 : FevVdP5MovJAiVEClsvBBQ==

none of them is same as our syncrypto results.

my code like this :

  
CONST
  KEY:RawByteString='123456';
VAR
  aKey: TSHA256Digest;
  AES:TAESECB;
  aa:TAESCFB;
  DAT:RawByteString;
  sr:RawByteString;
begin
  DAT:='ABC';
  aKey :=SHA256Digest(KEY);
  AES:=TAESECB.Create(aKey,256);
  sr:=AES.EncryptPKCS7(DAT);
  mmoLog.Lines.Add(BinToBase64(sr));
end;

result is EUouYChaLyxO7ArP0k3G4A==

what is your result with syncrypto?

#81 mORMot 1 » How to implement a Rest Api Gateway like zuul? » 2019-01-04 02:11:45

keinn
Replies: 3

We created some SOA rest servers use TSQLRestServerDB,
Like :OrderRestServer,MemberRestServer,ProductRestServer,DeliverRestServer ,etc..
Each RestServer Running in different process  deployed at different machine.

So we need to create one TSQLHttpClient for each *RestServer, so that is more then 5 TSQLHttpClient instance at client side (mobile app for example)

If app client need to get some data like: get all orders and delivery status of one member.
That's just so many calls need to made by app.

We think that is the wrong approach.

Is there a easy way to implement a Rest Api GateWay (like SpringCloud-Zuul or Kong), which combine many backend Rest Api within one http call?

Or is it the right way to do it like this: Use a dedicated Front Rest Server to provide the Aggregated Api , in this aggreated api ,we manually call all needed backend rest apis, then return the combined data to client?

(but this approach need the Front Aggregate Rest Server  to create so many httpclient instance to the backend rest server for each single client request)

Is there a better(efficient) way?(mORMot way of course)

Happy new year by the way.

#82 mORMot 1 » All demos compiled failed with delphi 10.3 Rio » 2018-12-28 17:34:32

keinn
Replies: 1

i pull the latest source from git, still cannot compile anything with 10.3(Rio). 
ide stopped at line 18794 in SynCommon.pas

error message:

[dcc32 Error] SynCommons.pas(18794): E2015 Operator not applicable to this operand type

ide stopped at

procedure TSynTempBuffer.Init(Source: pointer; SourceLen: integer);
begin
  len := SourceLen;
  if len<=0 then
    buf := nil else begin
    if len<=SizeOf(tmp)-16 then
      buf := @tmp else
      GetMem(buf,len+16); // +16 for trailing #0 and for PInteger() parsing
    MoveFast(Source^,buf^,len);
    PPtrInt(buf+len)^ := 0; // always init last 4/8 bytes (makes valgrid happy)  <<----------stopped here 
  end;
end;

all 36 demo projects failed

#83 Re: mORMot 1 » MainDemo cannot be compiled in Delphi » 2018-12-28 14:00:01

i pull the latest source from git, still cannot compile anything with 10.3(Rio). 
same problem , ide stopped at line 18794 in SynCommon.pas :  PPtrInt(buf+len)^ := 0; // always init last 4/8 bytes (makes valgrid happy)

#84 mORMot 1 » about the RAM usage » 2018-12-22 08:18:42

keinn
Replies: 1

we have similar usage like this:
https://synopse.info/forum/viewtopic.php?id=4712

many TSQLRestServerDB instance hosted in one httpserver,
we do this to preform "Each Client Has It's Own Database", and to practice the "Sharding"
this approach really simplify the  project's architecture and coding.

we have 1000 TSQLRestServerDB s hold in each Httpserver ,yes you see it right , 1000+

by test we fill two table of each database with One Million rows ,then each db file in disk is about 200M

we load all the 1000 databases, the project's whole RAM use is just around 300M, so we think with todays machine ablility ,
this will work just fine .

and we run 10+ process on each machine to get maxium use of the machine power.

if this work ok ,it will save a lot of money!! 

after reading the linked post above , we afriad  this approach may cause some other issue, like backup\ cache\ master\slave etc

any thought?

#85 mORMot 1 » when add new fileds to table,how to set defalut value to them » 2018-12-22 08:02:01

keinn
Replies: 0

hi,everyone
i need to update the table structure, add some more fileds to it,
but if we just add the new filed definition to the TSQLRecord,
the default value will be NULL at all old table row( old table have many rows ,not empty new table),
in practice , we need to fill default value to it .
i try the InitializeTable proc, but cannot find a proper way to do it .

anyone can post a sample code?
thanks very much.

#86 mORMot 1 » the lack of scale solution » 2018-10-27 02:52:20

keinn
Replies: 3

for example, our online services has many Couppon infomation , currently we use the ORM Rest Part of mORMot to serve the requests from all kinds of clients, such as browser ajax, mobile apps , pc clients.
something like this:

  TSQLCoupponInfo = class(TSQLRecord)
  private
    fId: TID;
    fProductName: RawUTF8;
    fManufactor: RawUTF8;
    fPrice:Currency;
    fCouppon:Currency;
    fDueTime:TDateTime;
    fCreatedAt: TCreateTime;
    fModifiedAt: TModTime;
   etc...
    
  published
    property id:TID read fId;
    property ProductName :rawuft8 read fProductName write ProductName;
    etc ...
    property CreatedAt: TCreateTime read fCreatedAt write fCreatedAt;
    property ModifiedAt: TModTime read fModifiedAt write fModifiedAt;

  end;

many table like this contains more then 20 fileds,and such table row count growing so fast (nearly 200 thousand per day),
now it contains nearly 5million rows .
the valid Couppon info is just the recent few days, we do not need to lookup the whole table,
but mORMot does not have a way to do something like :generate one table per day (or other strategy)

by this project, we build it all the mORMot rest way,  no stored proc, few table relation etc.
now we facing the rapid growing table size and massive client request(nearly 1million anonymous UV, 10million PV) , and our marketing invest will make the load way more heavy in the foreseeable future. not just the public services, many other services need auth also faceing the heavy requests.

now only thing we do ,it's just put many CDN server at Services's frontend and use more powerful machine. 
we go through all the mORMot doc and forum info,  we just found AB said that :you dont need scale or loadbalancing.

but we are so afraid that one day , our services just can't hold the request load anymore.
so, we need such sugestion:
1. table scale to control single table row count;
2. Rest Services load balancing.
and another thing , rest services really need version control .

we only use delphi to build or whole project, only 3 coder , and we love delphi/pascal , we really dont wanna switch to Java or Go solution.
maybe we used mORMot the wrong way . but any advice will be appreciated.
thanks very much.

#87 Re: mORMot 1 » question about TSQLHttpClientWinSock » 2018-05-24 14:38:43

i mean, i suffered "client not response" issue, when using the TSQLHttpClientWebsockets。 
when the client callback deal with long time process, it will block the websocket connection.
detailed here: https://synopse.info/forum/viewtopic.php?id=4547
is there a way to post the callback process to a dedicated backgroud thread? other than Client.ServiceNotificationMethodViaMessages()?,
sometimes there is no window form to process Tmessage loop.

#88 Re: mORMot 1 » websocket client callback theading problem » 2018-05-24 05:46:38

after deep dive into the synopse online doc, i think , the Client.ServiceNotificationMethodViaMessages(); will solve the problem.

but , another case, i use the websocket client in dll , and the dll is loaded by a third party exe ,not coded in delphi~~ wanna cry.

#89 mORMot 1 » websocket client callback theading problem » 2018-05-24 01:21:08

keinn
Replies: 1

question:how the webscoket client callback work? is it running in thread ? how to perform NoBlocking on client side?

while testing the sample 31: Project31ChatServer.dpr and Project31ChatClient.dpr. the default code works .
but if made one small change on the client side callback as such:

procedure TChatCallback.NotifyBlaBla(const pseudo, msg: string);
begin
  TextColor(ccLightBlue);
  writeln(#13'@',pseudo,' ',msg);
  TextColor(ccLightGray);
  write('>');
  sleep(60000); //just test the slow process
end;

and modify the procedure Run; make it send 10000 Blabla Requests as such:

     TextColor(ccLightGray);
     write('>');
     readln(msg);
     if msg='' then  exit;
     i:=0;
      repeat
        Service.BlaBla(pseudo,msg);
      until i=10000;

run  such modified client  , and the UnModified client together,  just for a short while, the client will raize:

 TInterfacedObjectFakeClient.FakeCall(IChatService.BlaBla) failed: 'URI root/ChatService.BlaBla ["888888888888","88888888888"] returned status 'Not Found' (404 - Network problem or request timeout)'

it seems due to the TChatCallback.NotifyBlaBla callback service take too long to process ,the webscoket client is closed by the server .
so my question is : when it's call by server, what thread does  the websocket callback implemetion running in? ie:TChatCallback.NotifyBlaBla(const pseudo, msg: string);

is it thread safe? and seems "NoBlocking" is not implement on both side

#90 Re: mORMot 1 » question about TSQLHttpClientWinSock » 2018-05-24 00:47:21

the websocket client suffered some Hung up problem

#91 mORMot 1 » feature request:MQTT ,redis client » 2018-03-20 09:11:46

keinn
Replies: 1

i just love mORMot very much, i wanna to do everything only with our mORMot,
but ,nowadays, we need to comunicate with outside world,
MQTT protocol and Redis are the mainstream solution now ,
i hknow there are some implemention out there , but  we wanna do it just use the mORmot codebase.

will you please consider?

#92 mORMot 1 » TipInfo:lightweight, embedd cross-platform js engine with delphi » 2018-03-01 10:29:36

keinn
Replies: 1

Looking to add JavaScript capabilities to you app, but without the bulk and overhead of JIT engines like V8, SpiderMonkey and Chakra? Then take a look at Duktape.

Duktape is a lightweight, embeddable and cross-platform JavaScript engine. It fits into a DLL just over half a megabyte in size but supports the complete ECMAScript 5.1 specification (as well as parts of ECMAScript 2015 and 2016).

https://blog.grijjy.com/2018/02/28/java … or-delphi/

https://github.com/svaarala/duktape

#93 Re: mORMot 1 » so many days now,so frustrated ,please help. » 2018-02-03 06:33:51

i read about sending rawbinary with interface service somewhere in the forum or doc,

If your purpose is to upload some binary data, RawByteString and TSQLRawBlob input parameters will by default be transmitted as Base64 encoded JSON text.
You may define Client-Server services via methods to transmit raw binary, without the Base64 encoding overhead. It would allow low-access to the input content type and encoding, even with multi-part file upload from HTTP.
As an alternative, if you use default TSQLRestRoutingREST routing, and defined a single RawByteString or TSQLRawBlob input parameter, it will be processed as a raw POST with binary body defined with mime-type 'application/octet-stream'. This may be more optimized for remote access over the Internet.
See https://synopse.info/fossil/info/4cfc722c69

1、if it RawByteString or  TSQLRawBlob input param will be default translate to base64 encoded , why i still need i.UploadPic(BinToBase64(Stringfromfile(PicFile)));??

2、TSQLRestRoutingREST , how to set routing to enable raw binary trasport? cant find in the doc

#94 Re: mORMot 1 » so many days now,so frustrated ,please help. » 2018-02-02 17:43:31

Thank you very much!
i followed your guide ,
now all the Down/Upload work very good, both vcl and fmx, both method and interface based service works great!
thanks again.
a strange issue though:
when implemting interface based upload service

  ISendFile=interface(IInvokable)
  ['{F62C36A1-1A6A-401E-B6B6-457FEB6A7E3F}']
    function UploadPic(Pic:RawByteString):RawUTF8;
  end;

//i have to use the base64toBin to decode the incoming data

function TSendFileServiceImpl.UploadPic(Pic: RawByteString): RawUTF8;
var
  FileName,FilePath:TFileName;
begin
  Result :='0';
  FileName :=UTF8ToString(Int64ToUtf8(UnixMSTimeUTC));
  FilePath :=ExeVersion.ProgramFilePath+'File\'+FileName;
  if FileFromString(base64toBin(Pic),FilePath,true,Now())=True then

  Result :=StringToUTF8(FileName);
end;

//vcl client side had to use the BinToBase64
  i := Self.Service<ISendFile>;
  if i <> nil then
   Result := i.UploadPic(BinToBase64(Stringfromfile(PicFile)));

any way to avoid use the base64toBin /BinToBase64 funcs?

another thing ,

function CallGetResult(const aCall: TSQLRestURIParams; var outID: integer): variant;

this function above in the SynCrossPlatformRest.pas will you please make it accessable global?
since i have to set the Call my self in my class inherited from TSQLRestClientHTTP like TCrossRestHttpClient = class(TSQLRestClientHTTP)
dont wanna to modify the mORMot source ,otherwise is hard to sync from the git trunc

#95 Re: mORMot 1 » so many days now,so frustrated ,please help. » 2018-02-01 20:08:28

i tried this :

server side:

procedure TMyRestServer.UpFile(Ctxt: TSQLRestServerURIContext);
var
  FileName:TFileName;
begin
  FileName :=UTF8ToString(Int64ToUtf8(UnixMSTimeUTC));
  if Ctxt.Method = mPOST then
  begin
      FileFromString(Ctxt.Call.InBody,fFileFolder+FileName);
      Ctxt.Success;
  end else Ctxt.Error('',HTTP_NOTFOUND);

end;

fmx client side:

function TCrossRestHttpClient.SendBlobData(aFileName:TFileName):string;
var
  Call:TSQLRestURIParams;
  dummyID: integer;
  dataToSent :string;
begin
  Log(sllServiceCall,'Method-based service %s',['UpFile']);

 dataToSent :=UTF8FileToString(aFileName);
  Call.Init(getURICallBack('UpFile',nil,0),'POST',dataToSent);
  URI(Call);
  result := CallGetResult(Call,dummyID);

end;

but the file saved on serverside is incorrect,
go throuh all the SynCrossPlatform* functions can NOT find the right one to load a file to a rawbytestring.

#96 mORMot 1 » so many days now,so frustrated ,please help. » 2018-02-01 17:30:15

keinn
Replies: 7

after days of searching through the whole document and the forum, i am so frustrated.
still dont know how to send a binray file to mORMot server by the mORMot CrossPlatform Firemonkey restclient..
i need to send a picture taking form the camera to the server,
but i found out that the current  mORMot  Crossplatform Wrapper generated fmx client
can NOT process binary file sending ,
even if i try to tranform the fire to rawbinarystring or tbytes or base64 encoded , all failed. so sad.
seems that the crossplatform client only deal with the json type

the server side i tried the Method based Service approach ,the interface based service approach, the Ctxt.InputAsMutilPart approach,
when sending from the VCL mormot restclient ,all them works fine .
but on fmx mobile client , dont know how to do so .

please please please help.
nowadays, function like sending picture、video、audio files  form phone is really really really important.
thanks.

#97 mORMot 1 » Fastest MD5 Hash algorithm On Earth! » 2018-01-30 09:34:57

keinn
Replies: 2

Faster than System.Hash ,Faster than Indy,and still 50% Faster than mORMot!!!
algorithm  :https://github.com/maximmasiutin/MD5_Transform-x64
Delphi transport: https://github.com/PassByYou888/FastMD5 … st_MD5.pas

#98 Re: mORMot 1 » Delphi10.2.2 2004 Compile Error » 2018-01-02 14:37:39

sorry , i reinstall the IDE again ,no compile errors at all . thks.

#99 mORMot 1 » Delphi10.2.2 2004 Compile Error » 2018-01-01 02:44:21

keinn
Replies: 2

So many Compile Errors while building use the latest Delphi 10.2 with update2.
already uses the latest mORMot codes from git clone.

[dcc32 Warning] mORMot.pas(15078): W1010 Method 'TerminatedSet' hides virtual method of base type 'TThread'
[dcc32 Error] mORMot.pas(29927): E2441 Inline function declared in interface section must not use local symbol 'Deref'
[dcc32 Error] mORMot.pas(39634): E2066 Missing operator or semicolon
[dcc32 Warning] mORMot.pas(45454): W1073 Combining signed type and unsigned 64-bit type - treated as an unsigned type
[dcc32 Error] mORMot.pas(53565): E2023 Function needs result type
[dcc32 Error] mORMot.pas(53570): E2023 Function needs result type
[dcc32 Error] mORMot.pas(53575): E2023 Function needs result type
[dcc32 Error] mORMot.pas(53579): E2029 '=' expected but ';' found
[dcc32 Error] mORMot.pas(53579): E2029 '=' expected but ';' found
[dcc32 Error] mORMot.pas(53581): E2029 Expression expected but 'BEGIN' found
[dcc32 Error] mORMot.pas(53593): E2004 Identifier redeclared: 'TInterfacedObjectFake'
[dcc32 Error] mORMot.pas(53595): E2003 Undeclared identifier: 'Obj'
[dcc32 Error] mORMot.pas(53607): E2023 Function needs result type
[dcc32 Error] mORMot.pas(53607): E2029 ';' expected but ')' found
[dcc32 Error] mORMot.pas(53608): E2029 Type expected but 'VAR' found
[dcc32 Error] mORMot.pas(53628): E2007 Constant or type identifier expected
[dcc32 Error] mORMot.pas(53870): E2004 Identifier redeclared: 'TInterfacedObjectFake'
[dcc32 Error] mORMot.pas(53871): E2029 '=' expected but ';' found
[dcc32 Error] mORMot.pas(53871): E2029 '=' expected but ';' found
[dcc32 Error] mORMot.pas(53872): E2029 ';' expected but identifier 'aParamValue' found
[dcc32 Error] mORMot.pas(53872): E2029 '=' expected but ')' found
[dcc32 Error] mORMot.pas(53879): E2003 Undeclared identifier: 'TInterfacedObjectFakeClient'
[dcc32 Error] mORMot.pas(53883): E2003 Undeclared identifier: 'fClient'
[dcc32 Error] mORMot.pas(53883): E2003 Undeclared identifier: 'aClient'
[dcc32 Error] mORMot.pas(53884): E2029 ')' expected but identifier 'fClient' found
[dcc32 Error] mORMot.pas(53887): E2035 Not enough actual parameters
[dcc32 Error] mORMot.pas(53890): E2004 Identifier redeclared: 'TInterfacedObjectFakeClient'
[dcc32 Error] mORMot.pas(53891): E2029 '=' expected but ';' found
[dcc32 Error] mORMot.pas(53891): E2029 '=' expected but ';' found
[dcc32 Error] mORMot.pas(53892): E2029 ';' expected but identifier 'aParamValue' found
[dcc32 Error] mORMot.pas(53892): E2029 '=' expected but ')' found
[dcc32 Error] mORMot.pas(53894): E2003 Undeclared identifier: 'W'
[dcc32 Error] mORMot.pas(53894): E2066 Missing operator or semicolon
[dcc32 Error] mORMot.pas(53894): E2029 'END' expected but ')' found
[dcc32 Error] mORMot.pas(53898): E2037 Declaration of 'TInterfacedObjectFakeClient' differs from previous declaration
[dcc32 Error] mORMot.pas(53900): E2003 Undeclared identifier: 'fClient'
[dcc32 Error] mORMot.pas(53900): E2066 Missing operator or semicolon
[dcc32 Error] mORMot.pas(53901): E2001 Ordinal type required
[dcc32 Error] mORMot.pas(53901): E2010 Incompatible types: 'Integer' and 'Pointer'
[dcc32 Error] mORMot.pas(53901): E2029 'END' expected but ']' found
[dcc32 Error] mORMot.pas(53902): E2029 ';' expected but 'INHERITED' found
[dcc32 Error] mORMot.pas(57165): E2066 Missing operator or semicolon
[dcc32 Error] mORMot.pas(57176): E2066 Missing operator or semicolon
[dcc32 Error] mORMot.pas(58320): E2066 Missing operator or semicolon
[dcc32 Error] mORMot.pas(58447): E2066 Missing operator or semicolon
[dcc32 Error] mORMot.pas(60387): E2003 Undeclared identifier: 'IgnoreComma'
[dcc32 Error] mORMot.pas(53475): E2065 Unsatisfied forward or external declaration: 'TInterfacedObjectFake.FakeCall'
[dcc32 Error] mORMot.pas(53491): E2065 Unsatisfied forward or external declaration: 'TInterfacedObjectFake.FakeQueryInterface'
[dcc32 Error] mORMot.pas(53492): E2065 Unsatisfied forward or external declaration: 'TInterfacedObjectFake.Fake_AddRef'
[dcc32 Error] mORMot.pas(53493): E2065 Unsatisfied forward or external declaration: 'TInterfacedObjectFake.Fake_Release'
[dcc32 Error] mORMot.pas(53497): E2065 Unsatisfied forward or external declaration: 'TInterfacedObjectFake.InterfaceWrite'
[dcc32 Error] mORMot.pas(53505): E2065 Unsatisfied forward or external declaration: 'TInterfacedObjectFake.Get'
[dcc32 Error] mORMot.pas(53511): E2065 Unsatisfied forward or external declaration: 'TInterfacedObjectFakeClient.InterfaceWrite'
[dcc32 Fatal Error] mORMot.pas(53514): E2226 Compilation terminated; too many errors

#100 mORMot 1 » how to do "one to one" or "one to many" from the CrossPlatform client » 2017-12-28 10:25:21

keinn
Replies: 1

there is no *Joined or *Many procedure in the crossplatform client.
how to query or oprate on master/child relationship tables.

Board footer

Powered by FluxBB