I'm using the MultipartFormDataContent to upload a file to a rest API. This is working well, but my questions focuses on the proper way to use the Add(...) method to include the file content. Currently I am doing such:
string fileName = "foobar.txt";
MultipartFormDataContent formContent = new MultipartFormDataContent();
ByteArrayContent byteArray = ...;
formContent.Add(byteArray, "file", fileName);
...
again, this works - I am trying to understand the parameters to the Add(...) method. In the MSDN documentation at: https://msdn.microsoft.com/en-us/library/system.net.http.multipartformdatacontent(v=vs.118).aspx
it has two add methods:
- Add(HttpContent, String)
- Add(HttpContent, String, String)
however neither has a description listed, and when drilling into the methods themselves, the parameters are only described (again without descriptions) as:
- HttpContent content, string name
- HttpContent content, string name, string fileName
so, my specific questions in this context are:
- What is the 'name' parameter? (the one I'm setting as "file")?
- Does this need to be the literal string "file" or can it be something else?
- How is it used?