Skip to content

Instantly share code, notes, and snippets.

@TimHeckel
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TimHeckel/b03f9ecc81ffa96ab303 to your computer and use it in GitHub Desktop.
Save TimHeckel/b03f9ecc81ffa96ab303 to your computer and use it in GitHub Desktop.
Recommendations on how to pipe this?
Iron Router route:
this.route("poster", {
where: "server"
, path: "/post"
, action: function() {
var size = 0;
var future = new Future();
var _dcb = future.resolver();
var _data = Meteor._wrapAsync(function(data) {
size += data.length;
console.log('Got chunk2: ' + data.length + ' total: ' + size);
});
this.request.on("data", _data);
this.request.on("end", function() {
console.log("ALL DONE");
this.response.end("Thanks");
});
this.request.on("error", function(e) {
console.log("ERROR: " + e.message);
});
}
});
All of this has to be run within a Fiber for large files, otherwise the `end` event never fires
unless I comment out the `response.end()` in the iron router code:
https://github.com/EventedMind/iron-router/blob/dev/lib/server/route_controller.js#L44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment