node.js - node, How to handle/catch pipe -
I have seen and read some tutorials which show that you can take a stream like a pipe and another Lego blocks , But I can not do anything to catch the pipe command while doing a stream pipe in an object.
What do I mean by how I create an object with a function, so that I can do this:
uploadWrapper = function (client, file, callback) {upload = function (client, file, callback) {var file = file // this.data = 'undefined' stream.WRitable.call (this); This.end = function () {if (this.Dataof this.data! == 'undefined') file.data = this.data callback (file.data, 200)} / var path = urlB.host ('upload' ) .object ('files', file.id) .action ('content'). Url // // client.upload (path, file, callback)} util.inherits (upload, stream. Proper) upload.prototype._write = task (piece, encoding, callback) {this.data = this.data + chunk.toString ('utf8') callback ()} new uploads (client, file, callback)} export.upload = uploadWrapper How do I get data when pipe to my object Handle me
I have seen but I can not really get anything about this (maybe I have not seen in the places of writing?).
Can anyone tell me right direction?
If it helps to know, then I want to be able to catch all the data streams and create a string that contains data with binary encoding; Whether it is from a file stream or a request stream from a server (i.e. data from a multipart request file).
EDIT: I updated the code to log the data
EDIT: I have decided it, now I can get the pipe data, give me the code Had to put in the wrapper that returned the function to the stream.
EDIT: Now a different problem, this.data is not stored in the _read way in the upload code in this. Data can be read . EDIT: OK, now I can deal with callback and hold data, I need to know how this data is being pipe or if it is a normal function is being used.
If you want to create your own stream that can be piped with pipes and / or, Then see the node.
Comments
Post a Comment