Пример #1
0
def download():
    import os
    dbname=request.args[0]
    ### for GAE only ###
    tablename,fieldname=request.args[1].split('.')[:2]
    uploadfield=eval(dbname)[tablename][fieldname].uploadfield
    filename=request.args[1]
    if isinstance(uploadfield,str):
        from gluon.contenttype import contenttype
        response.headers['Content-Type']=contenttype(filename)
        db=eval(dbname)
        rows=db(db[tablename][fieldname]==filename).select()
        return rows[0][uploadfield]
    ### end for GAE ###
    filename=os.path.join(request.folder,'uploads/',filename)
    return response.stream(open(filename,'rb'))
Пример #2
0
def download():
    import os
    dbname = request.args[0]
    ### for GAE only ###
    tablename, fieldname = request.args[1].split('.')[:2]
    uploadfield = eval(dbname)[tablename][fieldname].uploadfield
    filename = request.args[1]
    if isinstance(uploadfield, str):
        from gluon.contenttype import contenttype
        response.headers['Content-Type'] = contenttype(filename)
        db = eval(dbname)
        rows = db(db[tablename][fieldname] == filename).select()
        return rows[0][uploadfield]
    ### end for GAE ###
    filename = os.path.join(request.folder, 'uploads/', filename)
    return response.stream(open(filename, 'rb'))
Пример #3
0
def download():
    import os
    db = get_database(request)
    filename = request.args[1]
    print filename
    ### for GAE only ###
    table, field = filename.split('.')[:2]
    if table in db.tables and field in db[table].fields:
        uploadfield = db[table][field].uploadfield
        if isinstance(uploadfield, str):
            from gluon.contenttype import contenttype
            response.headers['Content-Type'] = contenttype(filename)
            rows = db(db[table][field] == filename).select()
            return rows[0][uploadfield]
    ### end for GAE ###
    path = os.path.join(request.folder, 'uploads/', filename)
    return response.stream(open(path, 'rb'))
Пример #4
0
def download():
    import os
    db=get_database(request)
    filename=request.args[1]
    print filename
    ### for GAE only ###
    table,field=filename.split('.')[:2]
    if table in db.tables and field in db[table].fields:
        uploadfield=db[table][field].uploadfield
        if isinstance(uploadfield,str):
            from gluon.contenttype import contenttype
            response.headers['Content-Type']=contenttype(filename)
            rows=db(db[table][field]==filename).select()
            return rows[0][uploadfield]
    ### end for GAE ###
    path=os.path.join(request.folder,'uploads/',filename)
    return response.stream(open(path,'rb'))