#1 2020-12-09 20:02:04

radexpol
Member
From: Poland, Krk
Registered: 2019-11-29
Posts: 116

Interfaced Based Methods - Sending attachments

What's is the best method of receiving files using SOA method, for example:

type
  IInteractions = interface(IInvokable)
    ['{75775F98-DCD5-455A-A0EE-06E25FF24683}']
    function SendEMail(const Subject, Plain, ToList: string; Attachments: ????) : TResponse;
end;

attachment should be a two fields structure like:

TAttachment = record
  Name: RAWUtf8;
  Value: RawByteString;
end;

Should I declare Attachments: ???? as Attachments: array of TAttachment or create a TCollection inherited class or ....?

Offline

#2 2020-12-09 20:57:37

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 211

Re: Interfaced Based Methods - Sending attachments

check the documentation (16.8.6.1.1.5. Sending raw binary).

Last edited by pvn0 (2020-12-09 20:57:57)

Offline

#3 2020-12-09 21:02:01

radexpol
Member
From: Poland, Krk
Registered: 2019-11-29
Posts: 116

Re: Interfaced Based Methods - Sending attachments

OK, but where is an information how to declare the list of attachments (array or dynarray or collection)?

Offline

#4 2020-12-09 21:18:30

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 211

Re: Interfaced Based Methods - Sending attachments

Yes you can use array of TAttachment, collections need to be registered for json serialization so you prob don't want that.

Whatever you use it's going to be converted and transmited as JSON, Value field or the entire record will be converted to Base64 text and sent as json text.

Last edited by pvn0 (2020-12-09 21:22:13)

Offline

#5 2020-12-09 21:39:04

radexpol
Member
From: Poland, Krk
Registered: 2019-11-29
Posts: 116

Re: Interfaced Based Methods - Sending attachments

Are you sure that I don't have to register record? Look at demo 37 , file ServFishShopTypes.pas

type
  TFish = packed record
    Name: RawUTF8;
    Price: currency;
    PictureURI: RawUTF8;
    ID: variant;
  end; // TSQLTable DynArraySave()
  TFishList = array of TFish;


initialization
  TJSONSerializer.RegisterCustomJSONSerializerFromText([
    TypeInfo(TFish), _TFish,
    TypeInfo(TFishDetailed), _TFishDetailed
    ])

Offline

#6 2020-12-10 08:20:21

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 211

Re: Interfaced Based Methods - Sending attachments

Offline

Board footer

Powered by FluxBB