#1 2015-04-17 08:55:51

remko
Member
Registered: 2015-04-17
Posts: 4

post multipart data

I need to send a zip file to a rest service as http(s) post with content-type multipart/form-data. The rest service will return json data to indicate success/failure.

I found this forum post: http://synopse.info/forum/viewtopic.php?id=2366 but is there any documentation on how to use it or perhaps a small example?

Offline

#2 2015-04-17 11:10:29

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: post multipart data

In end-user code, you should use TSQLRestServerURIContext.InputAsMultiPart in a method-based service.
See http://synopse.info/files/html/api-1.18 … C_436B0FC2

Offline

#3 2015-04-17 12:35:26

remko
Member
Registered: 2015-04-17
Posts: 4

Re: post multipart data

Thanks but I don't understand how this relates to the TWinHttp.Post request that I'd like to send:

  SetLength(MultiPart, 1);
  MultiPart[0].Name := 'file';
  MultiPart[0].FileName := ExtractFileName(Filename);
  MultiPart[0].ContentType := 'application/octet-stream';
  MultiPart[0].Encoding := 'UTF8';
  MultiPart[0].Content := Body;

  ctx := TSQLRestServerURIContext.Create;
  ctx.InputAsMultiPart(MultiPart);

  // what to do to send with TWinHttp.Post ?

Offline

#4 2015-04-17 13:19:49

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: post multipart data

Oh - I did not understand your exact question.
I though your were talking about the server part.

There is no multi-part mime encoding for the client yet in SynCrtSock.pas.
So you would have to use Indy or Synapse to compute the body, then send it via TWinHttp.Post().

Offline

Board footer

Powered by FluxBB