Click here to Skip to main content
15,884,537 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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

JavaScript
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 call the function from the recorder.js in main.js

JavaScript
function sendAudio() {
    Recorder.sendFile( doneEncoding );
}


i call the method in html
HTML
<button  önclick="saveAudio(this);"></button>


i use the method to retrieve the blob in my web service
C#
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";
    }
Posted
Updated 21-May-14 9:29am
v4
Comments
Sunasara Imdadhusen 21-May-14 8:19am    
Where is your code
Ignitius 21-May-14 8:43am    
which specific code
Kornfeld Eliyahu Peter 21-May-14 15:48pm    
I can't see where the stored file in this code!
Ignitius 22-May-14 0:54am    
The bloburl was created and currently gets placed in thw browser cache, im not sure how to retrieve it, so I assumed if I took the 'cb'/blob before the url is created, I assumed it should work, im relatively new to this
Kornfeld Eliyahu Peter 22-May-14 1:17am    
You can not retrieve cached content from the browser I'm afraid...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900