new bs.ByteReader(post.uploadStream)
The low-level file module uses ByteReader, so you can look to it for an
example. GitHub is down ATM, so here it is on mxr:
http://mxr.mozilla.org/labs-central/source/jetpack-sdk/packages/jetpack-core/lib/file.js#170
Drew
Thanks a lot for the help. Works like expected now.
-Sajal
Drew
Thanks again for your help. Works fine now.
I researched for a while before asking here... don't know how i missed that.
Is there any central repository of more user generated snippets from
were n00bs like me can learn by others code?
BTW, instead of the byte-streams module, ive ended up using this
function getPostData(subject){
subject.QueryInterface(components.interfaces.nsIUploadChannel);
var postData = subject.uploadStream;
var stream =
Cc["@mozilla.org/binaryinputstream;1"].createInstance(Ci.nsIBinaryInputStream);
stream.setInputStream(postData);
var postBytes = stream.readByteArray(stream.available());
var poststr = String.fromCharCode.apply(null, postBytes);
postData.QueryInterface(Ci.nsISeekableStream).seek(Ci.nsISeekableStream.NS_SEEK_SET,
0);
return poststr;
}
-Sajal