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'))
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'))
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'))
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'))