Skip to content

A small library for creating multipart/form-data content from flat stucture objects.

License

Notifications You must be signed in to change notification settings

hell03end/HttpMultipartFormDataFactory

Repository files navigation

HttpMultipartFormDataFactory

build NuGet version

A small library for creating multipart/form-data content from flat objects.

Usage

Create an instance of the MultipartFormDataFactory class or use MultipartFormDataFactory.Default static field, then pass it a request object:

var multipartFormDataFactory = new MultipartFormDataFactory();
var content = await multipartFormDataFactory.Create(request, token);

This will return a System.Net.Http.MultipartFormDataContent instance. Later is can be used in http client instance like this:

var response = await _httpClient.PostAsync(url, content, token);

IFormFile abstraction should be used for files.

Benchmarks

dotnet run -c RELEASE --project HttpMultipartFormDataFactory.Tests
Method Mean Error StdDev Gen 0 Gen 1 Allocated
CreateWithCache 639.1 us 5.75 us 5.38 us 227.5391 113.2813 569 KB
CreateWithoutCache 876.3 us 16.77 us 17.23 us 275.3906 137.6953 631 KB

About

A small library for creating multipart/form-data content from flat stucture objects.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages