IncomingForm = require('formidable').IncomingForm express = require 'express' util = require 'util' module.exports = app = express.createServer() profiler = require 'v8-profiler' app.use express.bodyParser() app.use express.methodOverride() app.use app.router app.configure 'development', -> app.use express.errorHandler dumpExceptions: on, showStack: true app.configure 'production', -> app.use express.errorHandler() app.use multipartBodyParser = (req, res, next) -> return next() unless /^multipart\/form-data/.test(req.headers['content-type']) console.log '--------------> UPLOAD <--------------' form = new IncomingForm() console.log req form.parse req req.body = {} # Body will be filled with usual form values req.files = [] # Files - array. form.on 'field' , (name, val) -> console.log name, val; req.body[name] = val form.on 'file' , (name, file) -> console.log name, file; req.files.push(file) form.on 'error' , (err) -> console.log err; next(err) form.on 'end' , () -> console.log 'end'; next() form.on 'aborted' , () -> console.log 'aborted'; next() form.on 'progress' , (bR, bE) -> console.log bR, bE; next() form.on 'fileBegin', (name, file) -> console.log name, file; next() app.get ///////, (req,res) -> res.send """
""" app.post '///////', (req, res) -> console.log "== Upload #{req.body.upload_type} (#{req.files.length} files) finished for #{req.radio.email}. Transcoding." # Request is successful anyway. res.send() #return unless req.files? and req.files.length > 0 and req.body?.upload_type? and req.body?.upload_id? console.log 'DONE' app.listen 7777