It reads the entire file into memory, then writes it out, not good for files large enough to consume a significant fraction of system memory.
On Jul 2, 6:48 pm, weheh <[email protected]> wrote: > Massimo, just for my personal edification, why won't > open(os.path.join(...,'wb').write(...read()) be suitable for writing > large files? What's a large file, anyway? > > On Jul 2, 8:27 pm, mdipierro <[email protected]> wrote: > > > No. For large files use this instead: > > > def index(): > > > form=FORM((INPUT(_type='file',_name='myfile'),INPUT(_type='submit')) > > if form.accepts(request.vars,session): > > > shutil.copyfileobj(form.myfile.file,open(os.path.join(request.folder,'static','filename.txt'),'wb')) > > response.flash='uploaded' > > return dict(form=form) > > > On 2 Lug, 19:06, Phyo Arkar <[email protected]> wrote: > > > > Thanks a lot! > > > this code can also write Large Files right? > > > > On Fri, Jul 2, 2010 at 11:48 PM, mdipierro <[email protected]> > > > wrote: > > > > > def index(): > > > > > form=FORM((INPUT(_type='file',_name='myfile'),INPUT(_type='submit')) > > > > if form.accepts(request.vars,session): > > > > > open(os.path.join(request.folder,'static','filename.txt'),'wb').write(form.myfile.file.read()) > > > > response.flash='uploaded' > > > > return dict(form=form) > > > > > but you need to come up with a safe way to generate a 'filename.txt' > > > > > On 2 Lug, 18:40, Phyo Arkar <[email protected]> wrote: > > > > > Anyway to Upload directly to Static Folder (none SQLForm, none DB) > > > > > And Serve file without streaming and going through Controller?

