 noflo = require 'noflo'
 express = require 'express'
+uuid = require 'node-uuid'
 
 class ReceiveFiles extends noflo.Component
   icon: 'files-o'

      file: new noflo.Port 'object'
      error: new noflo.Port 'object'

    @inPorts.in.on 'data', (request) =>
      if request.files
        @sendFiles(request)

  sendFiles: (request) ->
    return unless @outPorts.file.isAttached()
    for name, obj of request.files
      @outPorts.file.beginGroup uuid()
      @outPorts.file.send obj
      @outPorts.file.endGroup()

exports.getComponent = -> new ReceiveFiles
