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
clientHttpClientThe HttpClient for executing the request.
urlstringThe 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
clientHttpClientThe HttpClient for executing the request.
urlstringThe URL for the request.
headersDictionary<string, string>The additional headers.
Properties
Content
Gets the multipart form data content for the request.
public MultipartFormDataContent Content { get; }
Property Value
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
namestringThe name of the form field.
bytesbyte[]The byte array content.
fileNamestringThe file name.
contentTypestringThe 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
namestringThe name of the form field.
streamStreamThe file stream.
fileNamestringThe file name.
contentTypestringThe 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
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
expectedResponseTypeThe type expected by the response of the request.
cancellationTokenCancellationTokenThe cancellation token.
Returns
ExecuteAsync<TResponse>(CancellationToken)
Executes the network request.
public override Task<TResponse> ExecuteAsync<TResponse>(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<TResponse>
Returns the response of the request as the specified type.
Type Parameters
TResponseThe type of object returned from the request.