HttpMultipartContent HttpMultipartContent HttpMultipartContent HttpMultipartContent HttpMultipartContent Class

Definition

Provides HTTP content that uses the multipart/* MIME type.

public : sealed class HttpMultipartContent : IIterable<IHttpContent>, IClosable, IStringable, IHttpContent, IHttpMultipartContent
struct winrt::Windows::Web::Http::HttpMultipartContent : IIterable<IHttpContent>, IClosable, IStringable, IHttpContent, IHttpMultipartContent
public sealed class HttpMultipartContent : IEnumerable<IHttpContent>, IDisposable, IStringable, IHttpContent, IHttpMultipartContent
Public NotInheritable Class HttpMultipartContent Implements IEnumerable<IHttpContent>, IDisposable, IStringable, IHttpContent, IHttpMultipartContent
var httpMultipartContent = new httpMultipartContent();
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

Enumerating the collection in C# or Microsoft Visual Basic

You can iterate through an HttpMultipartContent object in C# or Microsoft Visual Basic. In many cases, such as using foreach syntax, the compiler does this casting for you and you won't need to cast to IEnumerable<IHttpContent> explicitly. If you do need to cast explicitly, for example if you want to call GetEnumerator, cast to IEnumerable with an IHttpContent constraint.

Constructors

HttpMultipartContent() HttpMultipartContent() HttpMultipartContent() HttpMultipartContent() HttpMultipartContent()

HttpMultipartContent(String) HttpMultipartContent(String) HttpMultipartContent(String) HttpMultipartContent(String) HttpMultipartContent(String)

Initializes a new instance of the HttpMultipartContent class with the specified MIME subtype.

public : HttpMultipartContent(Platform::String subtype)
HttpMultipartContent(winrt::hstring subtype) const;
public HttpMultipartContent(String subtype)
Public Sub New(subtype As String)
var httpMultipartContent = new httpMultipartContent(subtype);
Parameters
subtype
String String String

The MIME subtype of the multipart content.

Remarks

Below are the exceptions that this function throws.

E_INVALIDARG

The subtype parameter is null (Nothing in Visual Basic).

See Also

HttpMultipartContent(String, String) HttpMultipartContent(String, String) HttpMultipartContent(String, String) HttpMultipartContent(String, String) HttpMultipartContent(String, String)

Initializes a new instance of the HttpMultipartContent class with the specified MIME subtype and boundary string.

public : HttpMultipartContent(Platform::String subtype, Platform::String boundary)
HttpMultipartContent(winrt::hstring subtype, winrt::hstring boundary) const;
public HttpMultipartContent(String subtype, String boundary)
Public Sub New(subtype As String, boundary As String)
var httpMultipartContent = new httpMultipartContent(subtype, boundary);
Parameters
subtype
String String String

The MIME subtype of the multipart content.

boundary
String String String

The boundary string for the multipart content.

Remarks

Below are the exceptions that this function throws.

E_INVALIDARG

The subtype parameter is null (Nothing in Visual Basic).

The boundary parameter is null (Nothing in Visual Basic) or contains only white space characters or the boundary ends with a space character.

The length of the boundary parameter is greater than 70.

See Also

Properties

Headers Headers Headers Headers Headers

Get a collection of content headers set on the HttpMultipartContent.

public : HttpContentHeaderCollection Headers { get; }
HttpContentHeaderCollection Headers();
public HttpContentHeaderCollection Headers { get; }
Public ReadOnly Property Headers As HttpContentHeaderCollection
var httpContentHeaderCollection = httpMultipartContent.headers;
See Also

Methods

Add(IHttpContent) Add(IHttpContent) Add(IHttpContent) Add(IHttpContent) Add(IHttpContent)

Add HTTP content to the HttpMultipartContent instance.

public : void Add(IHttpContent content)
void Add(IHttpContent content) const;
public void Add(IHttpContent content)
Public Function Add(content As IHttpContent) As void
httpMultipartContent.add(content);
Parameters
content
IHttpContent IHttpContent IHttpContent

The HTTP content to add to HttpMultipartContent.

Remarks

Below are the exceptions that this function throws.

E_INVALIDARG

The content parameter is null (Nothing in Visual Basic).

BufferAllAsync() BufferAllAsync() BufferAllAsync() BufferAllAsync() BufferAllAsync()

Serialize the HttpMultipartContent into memory as an asynchronous operation.

public : IAsyncOperationWithProgress<ulong, ulong> BufferAllAsync()
IAsyncOperationWithProgress<ulong, ulong> BufferAllAsync() const;
public IAsyncOperationWithProgress<ulong, ulong> BufferAllAsync()
Public Function BufferAllAsync() As IAsyncOperationWithProgress( Of ulong )( Of ulong )
Windows.Web.Http.HttpMultipartContent.bufferAllAsync().done( /* Your success and error handlers */ );
Returns

Remarks

This operation will not block. The returned IAsyncOperationWithProgress(UInt64, UInt64) object will complete after all of the content has been written into memory.

The HttpMultipartContent class can be used to stream content that might be of arbitrary length. The BufferAllAsync method will fail if all of the HttpMultipartContent can't fit in memory.

Close() Close() Close() Close() Close()

Closes the HttpMultipartContent instance and releases allocated resources.

public : void Close()
void Close() const;
// This member is not implemented in C#
' This member is not implemented in VB.Net
// This member is not implemented in JavaScript

Remarks

The Close method releases allocated resources used by the HttpMultipartContent instance. The Close method can manage the lifetime of system resources (memory for the HttpMultipartContent, for example) used by a Windows Runtime object.

In the .NET Framework 4.5, this method projects as the Dispose method. In Visual C++ component extensions (C++/CX), this method projects as the destructor (delete operator).

Apps written in JavaScript, C#, or VB.NET use garbage collection to release resources. So the HttpMultipartContent object and associated resources doesn't get released until the garbage collection pass runs. The Close method allows an app to release these resources early rather than waiting for the object to be released by garbage collection.

Apps written in C++ or CX don't have a Close method since these apps can destroy the object. In C++ and CX, objects are released when they fall out of program scope or as part of the destructor (delete operator) for the object.

Dispose() Dispose() Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

// This member is not implemented in C++/CX
void Dispose()
Sub Dispose

First() First() First() First() First()

Gets an object that can be used to enumerate the contents in the HttpMultipartContent object.

public : IIterator<IHttpContent> First()
IIterator<IHttpContent> First() const;
// This member is not implemented in C#
' This member is not implemented in VB.Net
var iIterator = httpMultipartContent.first();
Returns

An object that can be used to enumerate the contents in the HttpMultipartContent object.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

Returns an enumerator that iterates through the collection.

// This member is not implemented in C++/CX
IEnumerator<T> GetEnumerator()
Function GetEnumerator As IEnumerator(Of T)
IEnumerator<T> GetEnumerator()
Returns

An enumerator that can be used to iterate through the collection.

ReadAsBufferAsync() ReadAsBufferAsync() ReadAsBufferAsync() ReadAsBufferAsync() ReadAsBufferAsync()

Serialize the HttpMultipartContent to a buffer as an asynchronous operation.

public : IAsyncOperationWithProgress<IBuffer, ulong> ReadAsBufferAsync()
IAsyncOperationWithProgress<IBuffer, ulong> ReadAsBufferAsync() const;
public IAsyncOperationWithProgress<IBuffer, ulong> ReadAsBufferAsync()
Public Function ReadAsBufferAsync() As IAsyncOperationWithProgress( Of IBuffer )( Of ulong )
Windows.Web.Http.HttpMultipartContent.readAsBufferAsync().done( /* Your success and error handlers */ );
Returns

Remarks

This operation will not block. The returned IAsyncOperationWithProgress(IBuffer, UInt64) object will complete after all of the content has been written to the buffer.

The HttpMultipartContent class can be used to stream content that might be of arbitrary length. The ReadAsBufferAsync method will fail if all of the HttpMultipartContent can't fit in memory since this method requires the entire content to be buffered in memory first.

ReadAsInputStreamAsync() ReadAsInputStreamAsync() ReadAsInputStreamAsync() ReadAsInputStreamAsync() ReadAsInputStreamAsync()

Serialize the HttpMultipartContent and return an input stream that represents the content as an asynchronous operation.

public : IAsyncOperationWithProgress<IInputStream, ulong> ReadAsInputStreamAsync()
IAsyncOperationWithProgress<IInputStream, ulong> ReadAsInputStreamAsync() const;
public IAsyncOperationWithProgress<IInputStream, ulong> ReadAsInputStreamAsync()
Public Function ReadAsInputStreamAsync() As IAsyncOperationWithProgress( Of IInputStream )( Of ulong )
Windows.Web.Http.HttpMultipartContent.readAsInputStreamAsync().done( /* Your success and error handlers */ );
Returns

Remarks

This operation will not block. The returned IAsyncOperationWithProgress(IInputStream, UInt64) object will complete after all of the content has been written to the stream.

ReadAsStringAsync() ReadAsStringAsync() ReadAsStringAsync() ReadAsStringAsync() ReadAsStringAsync()

Serialize the HttpMultipartContent to a String as an asynchronous operation.

public : IAsyncOperationWithProgress<Platform::String, ulong> ReadAsStringAsync()
IAsyncOperationWithProgress<winrt::hstring, ulong> ReadAsStringAsync() const;
public IAsyncOperationWithProgress<string, ulong> ReadAsStringAsync()
Public Function ReadAsStringAsync() As IAsyncOperationWithProgress( Of string )( Of ulong )
Windows.Web.Http.HttpMultipartContent.readAsStringAsync().done( /* Your success and error handlers */ );
Returns

Remarks

This operation will not block. The returned IAsyncOperationWithProgress(String, UInt64) object will complete after all of the content has been written to the String.

The HttpMultipartContent class can be used to stream content that might be of arbitrary length. The ReadAsStringAsync method will fail if all of the HttpMultipartContent can't fit in memory since this method requires the entire content to be buffered in memory first.

ToString() ToString() ToString() ToString() ToString()

Returns a string that represents the current HttpMultipartContent object.

public : Platform::String ToString()
winrt::hstring ToString() const;
public string ToString()
Public Function ToString() As string
var string = httpMultipartContent.toString();
Returns
string string string

A string that represents the current object.

TryComputeLength(UInt64) TryComputeLength(UInt64) TryComputeLength(UInt64) TryComputeLength(UInt64) TryComputeLength(UInt64)

Determines whether the HttpMultipartContent has a valid length in bytes.

public : Platform::Boolean TryComputeLength(unsigned __int64 length)
bool TryComputeLength(UInt64 length) const;
public bool TryComputeLength(UInt64 length)
Public Function TryComputeLength(length As UInt64) As bool
var bool = httpMultipartContent.tryComputeLength(length);
Parameters
length
UInt64 UInt64 UInt64

The length in bytes of the HttpMultipartContent.

Returns
bool bool bool

true if length is a valid length; otherwise, false.

Remarks

The TryComputeLength method calculates the content length for HTTP content in HttpMultipartContent. Headers set on the content are not included in the content length. This is useful for content types that are easy to calculate the content length.

If computing the content length is not possible or expensive (would require the system to buffer the whole content where the serialization would be expensive or require the system to allocate a lot of memory), this method can return false. If this method returns false, this implies that either chunked transfer is needed or the content must get buffered before being sent to the server.

WriteToStreamAsync(IOutputStream) WriteToStreamAsync(IOutputStream) WriteToStreamAsync(IOutputStream) WriteToStreamAsync(IOutputStream) WriteToStreamAsync(IOutputStream)

Write the HttpMultipartContent to an output stream as an asynchronous operation.

public : IAsyncOperationWithProgress<ulong, ulong> WriteToStreamAsync(IOutputStream outputStream)
IAsyncOperationWithProgress<ulong, ulong> WriteToStreamAsync(IOutputStream outputStream) const;
public IAsyncOperationWithProgress<ulong, ulong> WriteToStreamAsync(IOutputStream outputStream)
Public Function WriteToStreamAsync(outputStream As IOutputStream) As IAsyncOperationWithProgress( Of ulong )( Of ulong )
Windows.Web.Http.HttpMultipartContent.writeToStreamAsync(outputStream).done( /* Your success and error handlers */ );
Parameters
outputStream
IOutputStream IOutputStream IOutputStream

The output stream to write to.

Returns

Remarks

This operation will not block. The returned IAsyncOperationWithProgress(UInt64, UInt64) object will complete after all of the content has been written to the output stream.

See Also