   request      = Npm.require 'request'
   Throttle     = Npm.require 'throttle'
   fileType     = Npm.require 'file-type'
+  nodePath     = Npm.require 'path'
 
   ###
   @var {object} bound - Meteor.bindEnvironment (Fiber wrapper)

    start: ->
      self = @
      if @config.onBeforeUpload and _.isFunction @config.onBeforeUpload
        isUploadAllowed = @config.onBeforeUpload.call @result, @fileData
        if isUploadAllowed isnt true
          return @end new Meteor.Error(403, if _.isString(isUploadAllowed) then isUploadAllowed else 'config.onBeforeUpload() returned false')

      if @collection.onBeforeUpload and _.isFunction @collection.onBeforeUpload
        isUploadAllowed = @collection.onBeforeUpload.call @result, @fileData
        if isUploadAllowed isnt true
          return @end new Meteor.Error(403, if _.isString(isUploadAllowed) then isUploadAllowed else 'collection.onBeforeUpload() returned false')


      check @cacheControl, String
      check @onAfterUpload, Match.OneOf false, Function
      check @integrityCheck, Boolean
      check @onBeforeRemove, Match.OneOf false, Function
      check @downloadCallback, Match.OneOf false, Function
      check @interceptDownload, Match.OneOf false, Function

