C
C#6mo ago
engineertdog

Multipart form upload prepends the file

I have a 3rd party that I am uploading files to via C#. For some reason, it looks like C# is prepending the files with additional information prior to uploading them and I can't figure out where it is occurring. Example prepend to CSV or JSON files
--<file-hash>
Content-Disposition: form-data; name=file; filename=<file-name>;
filename*=utf-8''<file-name>
{
...
}
--<file-hash>
Content-Disposition: form-data; name=file; filename=<file-name>;
filename*=utf-8''<file-name>
{
...
}
c#
HttpClient client = new();
MutlipartFormDataContent formData = [];
FileStream fileStream = new("filepath", FileMode.Open, FileAccess.Read);
StreamContent fileContent = new(fileStream);
formData.Add(fileContent, "file", "filename.csv");
client.PutAsync("url", formData);
c#
HttpClient client = new();
MutlipartFormDataContent formData = [];
FileStream fileStream = new("filepath", FileMode.Open, FileAccess.Read);
StreamContent fileContent = new(fileStream);
formData.Add(fileContent, "file", "filename.csv");
client.PutAsync("url", formData);
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server