I have a client that uploads a file to an API (see code):
using (var client = new HttpClient())
{
using (var content = new MultipartFormDataContent())
{
// THIS LINE SHOULD BE CHANGED TO RETURN A Base64 StreamContent object
var fileContent = new StreamContent(File.OpenRead(txtFileLocation.Text));
fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
FileName = Path.GetFileName(@"C:\text.mp4")
content.Add(fileContent);
var result = client.PostAsync("http://localhost:1234/api/upload", content).Result;
}
}
The API expects a MIME base64 file.
I'm familiar with how to encode a file into a string base64. What I don't know is: how can I pass this string as a MIME File Upload to the API?