I have been working for capturing audio from browser and send the files to IIS Server. Followed recorderjs article from Matt Diamond. To upload the blob to server i got the reference from the link Voice Recorder, Saving Blob file to server - C# , Mvc. But am getting error unsupported media type 415. It was mentioned to look for custom [MimeType("audio/wav")] attribute in the data model. But unable to find the solution . Two days am running for the solution. Would be great if someone help out.
By following the link am getting the error .(https://i.stack.imgur.com/chrx8.png)
var fd = new FormData();
fd.append('FileName', 'test.wav');
fd.append('Recording', blob);
$.ajax({
type: 'POST',
dataType: 'application/json',
url: 'http://localhost:53387/api/RecordingWav/Upload',
data: fd,
processData: false,
contentType: false
}).done(function (data) {
console.log(data)
});
My controller code look like
public class RecordingWavController:ApiController{
[HttpPost]
public string Upload(Classmodel passage)
{
string path = System.Web.HttpContext.Current.Server.MapPath(string.Format("~/UploadedFiles/{0}.wav", assage.FileName));
passage.Recording.SaveAs(path);
return 'success';
}
}
Model look like
public class Classmodel
{
public string FileName { get; set; }
public HttpPostedFileBase Recording { get; set; }
}
Thanks in advance regards.