diff --git a/examples/upload/index.js b/examples/upload/index.js deleted file mode 100644 index 7f822ea..0000000 --- a/examples/upload/index.js +++ /dev/null @@ -1,51 +0,0 @@ - -/** - * Module dependencies. - */ - -var logger = require('koa-logger'); -var serve = require('koa-static'); -var parse = require('co-busboy'); -var koa = require('../..'); -var fs = require('fs'); -var app = koa(); - -// log requests - -app.use(logger()); - -// custom 404 - -app.use(function *(next){ - yield next; - if (this.body || !this.idempotent) return; - this.redirect('/404.html'); -}); - -// serve files from ./public - -app.use(serve(__dirname + '/public')); - -// handle uploads - -app.use(function *(next){ - // ignore non-POSTs - if ('POST' != this.method) return yield next; - - // multipart upload - var parser = parse(this); - var part; - - while (part = yield parser.part()) { - var stream = fs.createWriteStream('/tmp/' + Math.random()); - part.pipe(stream); - console.log('uploading %s -> %s', part.filename, stream.path); - } - - this.redirect('/'); -}); - -// listen - -app.listen(3000); -console.log('listening on port 3000'); \ No newline at end of file diff --git a/examples/upload/public/404.html b/examples/upload/public/404.html deleted file mode 100644 index eb559a4..0000000 --- a/examples/upload/public/404.html +++ /dev/null @@ -1,15 +0,0 @@ - -
-The page you requested cannot be found.
- - \ No newline at end of file diff --git a/examples/upload/public/index.html b/examples/upload/public/index.html deleted file mode 100644 index 8882344..0000000 --- a/examples/upload/public/index.html +++ /dev/null @@ -1,20 +0,0 @@ - - - -Try uploading multiple files at a time.
- - - \ No newline at end of file