I'm using Postman and my own Restsharp based client to send the audio file to the web API controller when size exceeded from 3 or 4 MB provider.FileData showing contains 0 files.
I also tried to use this but can't be solved the problem. var provider = new MultipartFileStreamProvider(root);
public async Task<HttpResponseMessage> UploadFile()
{
HttpRequestMessage request = this.Request;
if (!request.Content.IsMimeMultipartContent())
{
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
}
string root = System.Web.HttpContext.Current.Server.MapPath("~/App_Data/uploads");
var provider = new MultipartFormDataStreamProvider(root);
var task = await request.Content.ReadAsMultipartAsync(provider).
ContinueWith<HttpResponseMessage>(o =>
{
FileInfo finfo = new FileInfo(provider.FileData.First().LocalFileName);
string guid = Guid.NewGuid().ToString();
string fileName = guid + "_" + provider.FileData.First().Headers.ContentDisposition.FileName
.Replace("\"", "");
File.Move(finfo.FullName, Path.Combine(root, fileName));
return new HttpResponseMessage()
{
Content = new StringContent("File uploaded.")
};
}
);
return task;
}