def do_GET(self, serv):
    qs = get_qs(serv.path)
    if (('accessToken' not in qs) or (('path' not in qs) and ('id' not in qs))):
        serv.send_error(400)
        return
    tok = qs['accessToken'][0]
    userid = do_auth(tok)
    if (userid == None):
        serv.send_error(401)
        return
    if ('path' in qs):
        path = qs['path'][0]
    else:
        path = publicid_to_fileid(qs['id'][0])
    if (path == None):
        serv.send_error(404)
        return
    alog(('fetching file %s' % path))
    f = File(path, userid)
    if (f == None):
        serv.send_error(400)
        return
    if is_folder(f):
        serv.send_error(401)
        return
    print('diskpath:', f.diskpath)
    try:
        file = open(f.diskpath, 'rb')
    except OSError:
        serv.send_error(404)
        return
    body = file.read()
    file.close()
    serv.gen_headers('GET', len(body), 'application/octet-stream')
    serv.send_header('Content-Disposition', ('attachment; filename="%s"' % f.name))
    serv.wfile.write(body)
def do_GET(self, serv):
    qs = get_qs(serv.path)
    if (('accessToken' not in qs) or (('path' not in qs) and ('id' not in qs))):
        serv.send_error(400)
        return
    tok = qs['accessToken'][0]
    userid = do_auth(tok)
    if (userid == None):
        serv.send_error(401)
        return
    if ('path' in qs):
        path = qs['path'][0]
    else:
        path = publicid_to_fileid(qs['id'][0])
    if (path == None):
        serv.send_error(404)
        return
    alog(('fetching file %s' % path))
    f = File(path, userid)
    if (f == None):
        serv.send_error(400)
        return
    if is_folder(f):
        serv.send_error(401)
        return
    print('diskpath:', f.diskpath)
    try:
        file = open(f.diskpath, 'rb')
    except OSError:
        serv.send_error(404)
        return
    body = file.read()
    file.close()
    serv.gen_headers('GET', len(body), 'application/octet-stream')
    serv.send_header('Content-Disposition', ('attachment; filename="%s"' % f.name))
    serv.wfile.write(body)