         res.setHeader('Content-Type', 'text/json')
         res.send(results)
         res.end()
-        
+
   else
     Grid.gfs.collection('media').findOne query, (err, filedata) =>
       return errors.notFound(res) if not filedata

  unless req.body.name
    name = req.body.filename.split('.')[0]
    req.body.name = _.str.humanize(name)
  
  path = req.body.path or ''
  path = path[1...] if path and path[0] is '/'
  path = path[...path.length-2] if path and path[path.length-1] is '/'
  
  options =
    mode: 'w'
    filename: req.body.filename


savePNG = (req, res) ->
  options = createPostOptions(req)
  force = req.user.isAdmin() and req.body.force
  checkExistence options, res, force, (err) ->
    return errors.serverError(res) if err
    writestream = Grid.gfs.createWriteStream(options)
    img = new Buffer(req.body.b64png, 'base64')
