Table of Contents

Class MultipartFormDataPostNetworkRequest

Namespace
MADE.Networking.Http.Requests
Assembly
MADE.Networking.dll

Defines a network request for a POST call with multipart form data content.

public sealed class MultipartFormDataPostNetworkRequest : NetworkRequest, INetworkRequest
Inheritance
MultipartFormDataPostNetworkRequest
Implements
Inherited Members
Extension Methods

Constructors

MultipartFormDataPostNetworkRequest(HttpClient, string)

Initializes a new instance of the MultipartFormDataPostNetworkRequest class.

public MultipartFormDataPostNetworkRequest(HttpClient client, string url)

Parameters

client HttpClient

The HttpClient for executing the request.

url string

The URL for the request.

MultipartFormDataPostNetworkRequest(HttpClient, string, Dictionary<string, string>?)

Initializes a new instance of the MultipartFormDataPostNetworkRequest class.

public MultipartFormDataPostNetworkRequest(HttpClient client, string url, Dictionary<string, string>? headers)

Parameters

client HttpClient

The HttpClient for executing the request.

url string

The URL for the request.

headers Dictionary<string, string>

The additional headers.

Properties

Content

Gets the multipart form data content for the request.

public MultipartFormDataContent Content { get; }

Property Value

MultipartFormDataContent

Methods

AddByteArrayContent(string, byte[], string, string)

Adds byte array content to the multipart form data content.

public MultipartFormDataPostNetworkRequest AddByteArrayContent(string name, byte[] bytes, string fileName, string contentType = "application/octet-stream")

Parameters

name string

The name of the form field.

bytes byte[]

The byte array content.

fileName string

The file name.

contentType string

The content type of the file. Default is application/octet-stream.

Returns

MultipartFormDataPostNetworkRequest

The current request for chaining.

AddStreamContent(string, Stream, string, string)

Adds a file stream to the multipart form data content.

public MultipartFormDataPostNetworkRequest AddStreamContent(string name, Stream stream, string fileName, string contentType = "application/octet-stream")

Parameters

name string

The name of the form field.

stream Stream

The file stream.

fileName string

The file name.

contentType string

The content type of the file. Default is application/octet-stream.

Returns

MultipartFormDataPostNetworkRequest

The current request for chaining.

AddStringContent(string, string)

Adds a string value to the multipart form data content.

public MultipartFormDataPostNetworkRequest AddStringContent(string name, string value)

Parameters

name string

The name of the form field.

value string

The value of the form field.

Returns

MultipartFormDataPostNetworkRequest

The current request for chaining.

ExecuteAsync(Type, CancellationToken)

Executes the network request.

public override Task<object> ExecuteAsync(Type expectedResponse, CancellationToken cancellationToken = default)

Parameters

expectedResponse Type

The type expected by the response of the request.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<object>

Returns the response of the request as an object.

ExecuteAsync<TResponse>(CancellationToken)

Executes the network request.

public override Task<TResponse> ExecuteAsync<TResponse>(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation token.

Returns

Task<TResponse>

Returns the response of the request as the specified type.

Type Parameters

TResponse

The type of object returned from the request.