web2py AlterEgo
rock solid framework for agile and secure web applications
home
search
Edit page
Title:
Security Code:
Body:
(use
this
wiki markup)
> Since version 1.22, streaming is the default method used by web2py to serve files from the following directories: [web2py working folder]/application/[your app]/static/ [web2py working folder]/application/[your app]/uploads/ > For customised file serving function that overrides the default download behavior, web2py will automatically detect whether the returning object is a streaming object (an iterator), or a string object, and serve accordingly. Examples: # streams big file using default byte size for chunks def my_big_file_downloader(): ... ... import os filename=request.args[0] pathfilename=os.path.join(request.folder,'uploads/', filename) return response.stream(open(pathfilename,'rb'), chunk_size=10**6) # the old way def my_small_file_downloader(): ... import os import gluon.contenttype filename=request.args[0] response.headers['Content-Type']=gluon.contenttype.contenttype(filename) pathfilename=os.path.join(request.folder,'uploads/', filename) return open('pathfilename', 'rb').read() You call them with: http://[host]/[app]/[controller]/my_big_file_downloader/[filename in uploads] or http://[host]/[app]/[controller]/my_big_file_downloader/[filename in uploads]/[...] where [...] is the filename you want the downloading user to see. See also: Infinite data stream <http://mdp.cti.depaul.edu/AlterEgo/default/show/32>
Resources
Home
Version 1.51 (2008-11-19 14:48:02)
Examples
|
API
|
ORM
Compare
|
Django
|
TG
|
Rails
|
PHP
|
Java
Tutorial
|
Book
|
epydocs
Screencast short
|
long
|
shell
|
GAE
Online Demo
Interactive FAQ (AlterEgo)
Repository of free web2py apps
KPAX (the web2py CMS)
Model Builder
|
Layout Builder
Central Authentication Service
Users Group (free to join)
Development Trunk (svn)
Contact
Massimo Di Pierro
School of Computing
DePaul University
243 S. Wabash Ave
Chicago, IL 60604 (USA)
mdipierro@cs.depaul.edu