当文件名有特殊字符时,我会在 Request.Files[0].FileName 上收到一个奇怪的文件名。像“=?utf-8?B?U ...”之类的东西
要发送我正在做的文件:
ProgressMessageHandler progress = new ProgressMessageHandler();
progress.HttpSendProgress += OnHttpSendProgress;
HttpClient client = HttpClientFactory.Create(progress);
client.DefaultRequestHeaders.TransferEncodingChunked = true;
MultipartFormDataContent content = new MultipartFormDataContent();
var fileContent = new StreamContent(new FileStream(fileInfo.FullName, FileMode.Open));
content.Add(fileContent, "file", fileInfo.Name);
HttpRequestMessage message = new HttpRequestMessage();
message.Method = HttpMethod.Post;
message.Content = content;
message.RequestUri = uri;
var resultado = await client.SendAsync(message, CancellationToken);
我究竟做错了什么?
我正在使用 WebClient 一段时间:
WebClient client = new WebClient();
client.UploadProgressChanged += OnHttpSendProgress;
await client.UploadFileTaskAsync(uriBuilder.Uri, "POST", fileInfo.FullName);