Created
September 4, 2017 23:05
-
-
Save killtheliterate/4e0417afad44958d4706bf47e5f5ae74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Router = require('koa-router') | |
const body = require('koa-body') | |
const fs = require('fs') | |
const router = new Router() | |
const BASE_URL = '/upload' | |
router.put(BASE_URL, body({ multipart: true }), async (ctx) => { | |
const files = ctx.request.body.files | |
const keys = Object.keys(files) | |
keys.forEach(key => { | |
const file = files[key] | |
const reader = fs.createReadStream(file.path) | |
const writer = fs.createWriteStream(/* s3 */) | |
reader.pipe(writer) | |
}) | |
ctx.status = 200 | |
ctx.body = { | |
message: 'good jorb, budz' | |
} | |
}) | |
module.exports = router |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment