If you want to do this from a web page in a browser, as opposed to node.js, I previously wrote up a sample that might be helpful: