Skip to content
Myr

Merge branch 'fix-upload'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by visionmedia · committed by visionmedia · parents 0186659, acf0a65 · Browse files · 1 file+17 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+17 added−4 removed

  • other:+17 added−4 removed

1 file+17 added−4 removed

modified:lib/express/core.js+17 added-4 removed
217 unmodified lines
218 request.body = ''219 request.setBodyEncoding('binary')220 if (request.headers['content-type'] &&221 request.headers['content-type'].indexOf('multipart/form-data') !== -1) {222 var stream = new multipart.Stream(request)222 var stream = new multipart.Stream(request),223 promise = new process.Promise,224 pendingFiles = 0225 request.params = { post: {}}226 promise.timeout(set('upload timeout') || 5000)227 stream.addListener('part', function(part){228 if (part.filename) {229 var file = new File(part.tempfile = '/tmp/express-' + Number(new Date) + uid(), 'w')230 ++pendingFiles231 part.pos = 0232 part.addListener('body', function(chunk){229 file.write(chunk, part.pos, 'binary')233 file.write(chunk, part.pos, 'binary').addErrback(function(){234 promise.emitError.apply(promise, arguments)235 })236 part.pos += chunk.length237 })238 part.addListener('complete', function(){233 file.close()239 file.close().addCallback(function(){240 if (!--pendingFiles)241 promise.emitSuccess()242 }).addErrback(function(){243 promise.emitError.apply(promise, arguments)244 })245 mergeParam(part.name, part, request.params.post)246 })247 }248 else
3 unmodified lines
252 .addListener('complete', function(){253 if (part.buf.length)254 mergeParam(part.name, part.buf, request.params.post)255 })245 }).addListener('complete', function(){ self.route(request, response) })256 }).addListener('complete', function(){257 promise.addCallback(function(){ self.route(request, response) })258 })259 }260 else261 request262 .addListener('body', function(chunk){ request.body += chunk })
67 unmodified lines