我如何...将记录的blob发送到Web服务 [英] How do I...send a recorded blob to a web service
本文介绍了我如何...将记录的blob发送到Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个当前存储在内存中的blob,我想要一种获取该blob并将其发送到Web服务的方法。任何形式的帮助将不胜感激。
以下代码在我的recorder.js中发送blob到服务器
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) {
// Handle response.
alert(xhr.responseText); // handle response.
}
};
xhr.send(cb);
}
i从main.js中的recorder.js调用函数
i call the function from the recorder.js in main.js
function sendAudio() {
Recorder.sendFile( doneEncoding );
}
i在html中调用方法
i call the method in html
<button önclick="saveAudio(this);"></button>
i使用方法来检索我的网络服务中的blob
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";
}
推荐答案
这篇关于我如何...将记录的blob发送到Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文