       if req.headers['if-modified-since'] is filedata.uploadDate
         res.status(304)
         return res.end()
-  
+
       res.setHeader('Content-Type', filedata.contentType)
       res.setHeader('Last-Modified', filedata.uploadDate)
       res.setHeader('Cache-Control', 'public')

    objectId = mongoose.Types.ObjectId(path)
    query = objectId
  catch e
    path = path.split('/')    
    filename = path[path.length-1]
    path = path[...path.length-1].join('/')
    query =


saveURL = (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)
    request(req.body.url).pipe(writestream)
