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):
        elog('Invalid access in file api')
        serv.send_error(401)
        return
    if ('id' in qs):
        path = publicid_to_fileid(qs['id'][0])
    else:
        path = qs['path'][0]
        path = urllib.unquote(path).strip()
    print('PATHPATH', path)
    dir = File(path, userid)
    if ('..' in path):
        serv.send_error(401)
        return
    if (not serv_all_local):
        prefix = files_root
        try:
            os.makedirs(prefix)
        except FileExistsError:
            pass
    dirpath = local_to_real(path)
    files = []
    for f in listdir(dirpath):
        path2 = ((path + os.path.sep) + f)
        file = File(path2, userid)
        f = {}
        if (file == None):
            continue
            print('error!', dirpath)
        f['name'] = file.name
        f['id'] = file.id
        f['mimeType'] = file.mimeType
        f['is_dir'] = (1 if file.is_dir else 0)
        f['parentid'] = file.parentid
        files.append(f)
    body = jsondumps({'items': files})
    body = bstr(body)
    serv.gen_headers('GET', len(body), json_mimetype)
    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):
        elog('Invalid access in file api')
        serv.send_error(401)
        return
    if ('id' in qs):
        path = publicid_to_fileid(qs['id'][0])
    else:
        path = qs['path'][0]
        path = urllib.unquote(path).strip()
    print('PATHPATH', path)
    dir = File(path, userid)
    if ('..' in path):
        serv.send_error(401)
        return
    if (not serv_all_local):
        prefix = files_root
        try:
            os.makedirs(prefix)
        except FileExistsError:
            pass
    dirpath = local_to_real(path)
    files = []
    for f in listdir(dirpath):
        path2 = ((path + os.path.sep) + f)
        file = File(path2, userid)
        f = {}
        if (file == None):
            continue
            print('error!', dirpath)
        f['name'] = file.name
        f['id'] = file.id
        f['mimeType'] = file.mimeType
        f['is_dir'] = (1 if file.is_dir else 0)
        f['parentid'] = file.parentid
        files.append(f)
    body = jsondumps({'items': files})
    body = bstr(body)
    serv.gen_headers('GET', len(body), json_mimetype)
    serv.wfile.write(body)