I have a blob which currently is stored in memory, I would like a way to get that blob and send it to a web service. Any kind of help would be appreciated.
the following code is in my recorder.js to send blob to server
Recorder.sendFile = function(cb, filename) {
var uri = "http://localhost/TestWebService/UploadService.asmx?op=UploadAudio";
var xhr = new XMLHttpRequest();
xhr.open("POST", uri, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
alert(xhr.responseText);
}
};
xhr.send(cb);
}
i call the function from the recorder.js in main.js
function sendAudio() {
Recorder.sendFile( doneEncoding );
}
i call the method in html
<button önclick="saveAudio(this);"></button>
i use the method to retrieve the blob in my web service
public string UploadAudio(byte[] file)
{
string straudioPath;
straudioPath = "~App_Data/";
FileStream objfilestream = new FileStream(straudioPath, FileMode.Create, FileAccess.ReadWrite);
objfilestream.Write(file, 0, file.Length);
objfilestream.Close();
return "OK";
}