server/node_modules/restler/lib/multipartform.js in vulcan-0.3.0 vs server/node_modules/restler/lib/multipartform.js in vulcan-0.4.0

- old
+ new

@@ -1,7 +1,7 @@ var fs = require('fs'); -var sys = require("sys") +var sys = require('util') exports.defaultBoundary = '48940923NODERESLTER3890457293'; // This little object allows us hijack the write method via duck-typing // and write to strings or regular streams that support the write method. @@ -107,11 +107,11 @@ //Now write out the body of the Part if (this.value instanceof File) { fs.open(this.value.path, "r", 0666, function (err, fd) { if (err) throw err; - position = 0; + var position = 0; (function reader () { fs.read(fd, 1024 * 4, position, "binary", function (er, chunk) { if (er) callback(err); stream.write(chunk); @@ -140,27 +140,28 @@ this.partNames = this._partNames(); } MultiPartRequest.prototype = { _partNames: function() { - partNames = [] - for (var name in this.data) { - partNames.push(name) + var partNames = []; + for (var name in this.data) { + partNames.push(name) } return partNames; }, + write: function(stream, callback) { var partCount = 0, self = this; // wrap the stream in our own Stream object // See the Stream function above for the benefits of this var stream = new Stream(stream); // Let each part write itself out to the stream (function writePart() { - partName = this.partNames[partCount]; - part = new Part(partName, self.data[partName], self.boundary); + var partName = self.partNames[partCount]; + var part = new Part(partName, self.data[partName], self.boundary); part.write(stream, function (err) { if (err) { callback(err); return; } @@ -197,6 +198,6 @@ } } Object.keys(exportMethods).forEach(function(exportMethod) { exports[exportMethod] = exportMethods[exportMethod] -}) \ No newline at end of file +})