       extension: extension
 
     result._id = fileId
-    console.info "[FilesCollection] [write]: #{fileName} -> #{@collectionName}" if @debug
 
     stream = fs.createWriteStream opts.path, {flags: 'w', mode: @permissions}
     stream.end buffer, (error) -> bound ->


        self.collection.insert _.clone(result), (error) ->
          if error
            console.warn "[FilesCollection] [addFile] [insert] Error: #{fileName} -> #{self.collectionName}", error if self.debug
            callback and callback error
          else
            console.info "[FilesCollection] [addFile] [insert]: #{fileName} -> #{self.collectionName}" if self.debug
            callback and callback null, result
      else
        callback and callback new Meteor.Error 400, "[FilesCollection] [addFile(#{path})]: File does not exist"


        self.collection.insert _.clone(result), (error) ->
          if error
            callback and callback error
            console.warn "[FilesCollection] [write] [insert] Error: #{fileName} -> #{self.collectionName}", error if self.debug
          else
            callback and callback null, result
            console.info "[FilesCollection] [write]: #{fileName} -> #{self.collectionName}" if self.debug
    return @
  else
    undefined
