I have a requirement of uploadng the file to Server in Win8.1 PCL project.
Windows.Web.Http.HttpClient.
I tried in Advanced Rest Client and it works fine
PFA @ http://i.stack.imgur.com/N8cv5.png
I have the Code like this.
Windows.Web.Http.HttpRequestMessage request = new Windows.Web.Http.HttpRequestMessage(Windows.Web.Http.HttpMethod.Post, uri);
HttpStreamContent streamContent = new HttpStreamContent(stream.AsInputStream());
streamContent.Headers.Add("Content-Type", "multipart/form-data; boundary=" + boundary);
streamContent.Headers.Add("Content-Length", stream.Length.ToString());
streamContent.Headers.Add("Content-Disposition", "form-data; name=\"" + flKey + "\"; filename=\"" + fleNm + "\"");
request.Content = streamContent;
var httpClient = new Windows.Web.Http.HttpClient();
var cts = new CancellationTokenSource();
Windows.Web.Http.HttpResponseMessage response = await httpClient.SendRequestAsync(request).AsTask(cts.Token);
String resp = response.Content.ToString();
这不起作用。请告诉我代码有什么问题,为什么这段代码无法将文件写入服务器。
Thanks in Advance