feat(econnect): Aktualisierung von PostAsync zur Verwendung des Inhaltstyps „application/pdf“ und Vereinfachung der Erstellung von Mehrteilformularen
- Generischer Header „multipart/form-data“ wurde durch „application/pdf“ für Dateiinhalte ersetzt - Erstellung von Mehrteilformularen wurde zur Verbesserung der Übersichtlichkeit und Korrektheit umstrukturiert - Es wurde sichergestellt, dass Dateistream und Dateiname direkt zum Mehrteilformular hinzuge
This commit is contained in:
parent
e8fd49d75d
commit
9256dc6baf
@ -130,20 +130,21 @@ public class EConnectClient<TError> : IEConnectClient<TError> where TError : cl
|
||||
{
|
||||
route = AddQueryString(route, queryParams);
|
||||
|
||||
// Create multipart form data content
|
||||
using var content = new MultipartFormDataContent();
|
||||
|
||||
// add file with Stream and fileName
|
||||
content.Add(new StreamContent(stream), "file", fileName);
|
||||
|
||||
// add file type
|
||||
content.Headers.ContentType = new MediaTypeHeaderValue("multipart/form-data");
|
||||
|
||||
// create message and add accept header
|
||||
using var message = new HttpRequestMessage(HttpMethod.Post, route);
|
||||
message.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("*/*"));
|
||||
|
||||
message.Content = content;
|
||||
// add file type
|
||||
var fileContent = new StreamContent(stream);
|
||||
fileContent.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
|
||||
|
||||
// Create multipart form data form
|
||||
using var form = new MultipartFormDataContent
|
||||
{
|
||||
{ fileContent, "file", fileName }
|
||||
};
|
||||
|
||||
message.Content = form;
|
||||
|
||||
var res = await Http.SendAsync(message, cancel);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user