Discuss this help topic in SecureBlackbox Forum

HTTPS: POST several data streams in one call

TElHTTPSClient.PostMultipart method is used to post multiple data streams in one request. The method accepts TElHTTPMultipartList object that contains all data to post.


TElHTTPSClient c = new TElHTTPSClient();
TElHTTPMultipartList list = new TElHTTPMultipartList();

// add some form field
list.AddFormField("field", "value");

// add a file stream
FileStream fs = new FileStream(...);
list.AddFormFile("input_file", "test.html", "text/html", fs, true);

// post multiple parts
c.PostMultipart("http://target.url", TSBHTTPMultipartMode.hmpFormData, list);

  client : TElHTTPSClient;
  fileStream : TMemoryStream;
  List : TElHTTPMultipartList;
client := TElHTTPSClient.Create(nil);

fileStream := TMemoryStream.Create;
// put some data to send here.
fileStream.Position := 0;

List := TElHTTPMultipartList.Create;
// add form fields
list.AddFormField('FieldName2', 'FieldValue2');

// add a stream
list.AddFormFile("input_file", "test.html", "text/html", fileStream, true);

// post multiple parts
client.PostMultipart('http://target.url', TSBHTTPMultipartMode.hmpFormData, list);

How To articles about client-side HTTPS questions

Discuss this help topic in SecureBlackbox Forum