На стороне клиента я продвинулся вот так:
Код: Выделить всё
HttpClient client = new HttpClient();
...
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(?); // TODO: What should I enter here?
using (var content = new MultipartFormDataContent())
{
var fileContent = new ByteArrayContent(bytes);
fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data");
fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
FileName = "My.dat"
};
content.Add(fileContent);
var response = await client.PostAsync(url, content);
response.EnsureSuccessStatusCode();
return response.Headers.Location;
}
Код: Выделить всё
Status Code: 500, ReasonPhrase: 'could not find expected boundary'
На стороне сервера, как мне извлечь байты из параметр запроса?
Код: Выделить всё
public async Task ReceiveFile(
HttpListenerRequest request,
...)
{
...
if (request.HasEntityBody)
{
// TODO: Save bytes to a file
}
...
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... r-via-rest