1 | (function() {
|
2 | var UploadStream, stream, util;
|
3 |
|
4 | stream = require("stream");
|
5 |
|
6 | util = require("util");
|
7 |
|
8 | UploadStream = function(options) {
|
9 | this.boundary = options.boundary;
|
10 | stream.Transform.call(this, options);
|
11 | };
|
12 |
|
13 | util.inherits(UploadStream, stream.Transform);
|
14 |
|
15 | UploadStream.prototype._transform = function(data, encoding, next) {
|
16 | var buffer;
|
17 | buffer = ((Buffer.isBuffer(data)) ? data : new Buffer(data, encoding));
|
18 | this.push(buffer);
|
19 | next();
|
20 | };
|
21 |
|
22 | UploadStream.prototype._flush = function(next) {
|
23 | this.push(new Buffer("\r\n", 'ascii'));
|
24 | this.push(new Buffer("--" + this.boundary + "--", 'ascii'));
|
25 | return next();
|
26 | };
|
27 |
|
28 | module.exports = UploadStream;
|
29 |
|
30 | }).call(this);
|
31 |
|
32 |
|