libcURL.MIMEMessage.AddElement - charonn0/RB-libcURL GitHub Wiki
Method Signatures
Sub AddElement(Name As String, Value As String, AdditionalHeaders As libcURL.ListPtr = Nil, Encoding As libcURL.TransferEncoding = libcURL.TransferEncoding.Binary)
Sub AddElement(Name As String, Value As FolderItem, FileName As String = "", ContentType As String = "", AdditionalHeaders As libcURL.ListPtr = Nil, Encoding As libcURL.TransferEncoding = libcURL.TransferEncoding.Binary)
Sub AddElement(Name As String, ValueStream As Readable, ValueSize As Integer, Filename As String = "", ContentType As String = "", AdditionalHeaders As libcURL.ListPtr = Nil, Encoding As libcURL.TransferEncoding = libcURL.TransferEncoding.Binary)
Sub AddElement(Name As String, Value As libcURL.MIMEMessage, AdditionalHeaders As libcURL.ListPtr = Nil)
Parameters
AddElement(String, String, libcURL.ListPtr, libcURL.TransferEncoding)
| Name |
Type |
Comment |
| Name |
String |
The name of the message part. |
| Value |
String |
The content of the part. |
| AdditionalHeaders |
ListPtr |
Optional. Additional MIME headers to include in the part. |
| Encoding |
TransferEncoding |
Optional. How to encode the part (defaults to binary). |
AddElement(String, FolderItem, String, String, libcURL.ListPtr, libcURL.TransferEncoding)
| Name |
Type |
Comment |
| Name |
String |
The name of the message part. |
| Value |
FolderItem |
The file to encode in the part. |
| FileName |
String |
Optional. The file name to use (overrides Value.Name) |
| ContentType |
String |
Optional. The Content-Type of the file (e.g. text/html.) |
| AdditionalHeaders |
ListPtr |
Optional. Additional MIME headers to include in the part. |
| Encoding |
TransferEncoding |
Optional. How to encode the part (defaults to binary). |
AddElement(String, Readable, Integer, String, String, libcURL.ListPtr, libcURL.TransferEncoding)
| Name |
Type |
Comment |
| Name |
String |
The name of the message part. |
| ValueStream |
Readable |
The stream from which to read the contents of the message part when they are actually needed. Use a BinaryStream to automatically "rewind" the stream after each use. |
| ValueSize |
Integer |
The total number of bytes to read from ValueStream. Pass 0 to read until ValueStream.EOF |
| Filename |
String |
Optional. If specified then the message part is encoded as a file part. |
| ContentType |
String |
Optional. The Content-Type of the file (e.g. text/html.) This parameter is ignored if Filename is not specified. |
| AdditionalHeaders |
ListPtr |
Optional. Additional MIME headers to include in the part. |
| Encoding |
TransferEncoding |
Optional. How to encode the part (defaults to binary). |
AddElement(String, libcURL.MIMEMessage, libcURL.ListPtr)
| Name |
Type |
Comment |
| Name |
String |
The name of the message part. |
| Value |
MIMEMessage |
Another MIMEMessage to be used as a sub-part. |
| AdditionalHeaders |
ListPtr |
Optional. Additional MIME headers to include in the part. |
Remarks
Pass a string to set a string part or a folderitem to set a file upload part. You may also pass a Readable object to have libcURL read from when the message part contents are needed, or a subordinate MIMEMessage to be encoded as a sub-part.
You may add custom MIME headers in the message part by specifying the AdditionalHeaders parameter.
Example
This example POSTs an HTTP form containing a string part, a file part with additional MIME headers, and a Readable part:
Dim c As New cURLClient
Dim form As New libcURL.MIMEMessage(c.EasyHandle)
form.AddElement("Username", "Bob")
Dim mimeheaders As New libcURL.ListPtr
mimeheaders.Append("X-Custom-Header: CustomValue")
Dim file As FolderItem = GetOpenFolderItem("")
form.AddElement("Upload", file, "", "", mimeheaders)
Dim testdata As MemoryBlock = "This is a test buffer."
Dim stream As New BinaryStream(testdata)
form.AddElement("Stream", stream, stream.Length)
If c.Post("http://www.example.com/submit.php", form) Then
MsgBox("Success!")
End If
See also