You are not logged in.
Hi All
I'm a newbie trying to understand the mORMot framework. Working with Sample 26 - the RESTful sever and client.
In RestServerClass.pas on ln 69 I get an error
procedure TNoteServer.Blob(Ctxt: TSQLRestServerURIContext);
var AFileName: TFileName;
begin
if (Ctxt.Table = TSQLNoteFile) and (Ctxt.TableID<>0) then
begin
AFileName := fBlobFolder+UTF8ToString(OneFieldValue(TSQLNoteFile,'FileName',Ctxt.TableID));
case Ctxt.Method of
mGET:
Ctxt.ReturnFile(AFileName);
mPOST,mPUT:
begin
FileFromString(Ctxt.Call.InBody, AFileName); // ln 69: MG Ctxt.Call.InBody is an ""Illegal qualifier" error in Lazarus - why? Its OK in Delphi
Ctxt.Success;
end;
mDELETE:
if DeleteFile(AFileName) then
Ctxt.Success else
Ctxt.Error('',HTTP_NOTFOUND);
end;
end;
end;
// ln 69: MG Ctxt.Call.InBody is an ""Illegal qualifier" error in Lazarus - why? Its OK in Delphi
I think I understand that this code is retrieving a filename from the ORM data table and if the HTTP request is an mPOST or mPUT then trying to save the BLOB data to file.
InBody is the REST request's content presumably. Please advise if this is the case and also why the error. This code works in Delphi 10.1.2
Many thanks
Martin
Offline
This is the default FPC behavior: pointers to records should explicitly be dereferenced via ^ whereas Delphi is more relax about it.
See e.g. http://forum.lazarus.freepascal.org/ind … pic=9521.0
You have to enable the "delphi mode" of FPC compilation, by using conditionals.
The easiest is to add in the beginning of all your units:
{$I Synopse.inc} // define HASINLINE and some FPC-specific options
Offline
Thx Arnaud,
Including the Synopse.inc declaration (and also adding that file's path to the project options include files path) fixed it, so now the project compiles.
Or equally making an explicit pointer declaration for the InBody field
FileFromString(Ctxt.Call^.InBody, AFileName); // changed from FileFromString(Ctxt.Call.InBody, AFileName);
also worked.
Many thanks Arnaud
Martin
Offline