     db.get params.id, (err, doc) =>
         if err and err.error == "not_found"
             app.locker.removeLock @lock
-            deleteFiles req, -> send error: err.error, 404
+            deleteFiles req, -> send error: "not found", 404
         else if err
             console.log "[Attachment] err: " + JSON.stringify err
             app.locker.removeLock @lock

                console.log "[Attachment] err: " + JSON.stringify err
                deleteFiles req, -> send error: err.error, 500
            else
                deleteFiles req, -> send success: true, msg: 'created', 201

        fs.createReadStream(file.path).pipe(stream)

    else
        console.log "no doc for attachment"

        send error: true, msg: "No file send", 400


# GET /data/:id/attachments/:name


    stream = db.getAttachment @doc.id, name, (err) ->
        if err and err.error = "not_found"
            send error: "not found", 404
        else if err
            send error: err.error, 500
        else
            send success: true, 200

    if req.headers['range']?
        stream.setHeader('range', req.headers['range'])
