0

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.

Rejish
  • 13
  • 2
  • 7
  • Did you see https://stackoverflow.com/questions/28369529/how-to-setup-a-webapi-controller-for-multipart-form-data – Shyju Nov 01 '17 at 13:47
  • did you check if the IIS MIME list has "audio/wav" – Shrugo Nov 01 '17 at 13:51
  • Shyju . Thanks . i have added config.Formatters.XmlFormatter.SupportedMediaTypes.Add(new System.Net.Http.Headers.MediaTypeHeaderValue("multipart/form-data")); in webapiconfig. earlier issue is over. but model is getting null value. Any idea for that. What could be the issue. – Rejish Nov 01 '17 at 14:13
  • Shrugo . Just checked thanks it has. – Rejish Nov 01 '17 at 14:14

0 Answers0