Unit

ScHttpMultipartData

 

Description

The TScHttpClientMultipartDataList class is designed for use with TScHttpWebRequest and implements writing data to its RequestStream property in the multipart/form-data format, as defined in RFC 7578.

 

This following example shows how to convert a list of files into the Parts list and populate the RequestStream property of the associated TScHttpWebRequest. The TScHttpWebRequest object must be created before it is associated with the TScHttpClientMultipartDataList object.

 

if OpenDialog.Execute then begin

 Parts := TScHttpClientMultipartDataList.Create(WebRequest);

 try

   for i := 0 to OpenDialog.Files.Count - 1 do begin

     FileName := ExtractFileName(OpenDialog.Files[i]);

     Parts.AddPart(ChangeFileExt(FileName, ''),

       FindMIMEType(FileName)).FileName := OpenDialog.Files[i];

   end;

   Parts.SaveStream;

 finally

   Parts.Free;

 end;

end;

 

Check also the example in the Demos\WebRequest\ directory.

 

See also

TScHttpMultipartDataList

TScHttpWebRequest.RequestStream

Parts

SecureBridge Components, Copyright © 2007-2026 Devart. All Rights Reserved. Provide Feedback Visit Forum Request Support
╳