[web2py] Re: Web2py Upload Function

2010-04-25 Thread mdipierro
No. you can use the download() action already provided in default.py Should work out of the box. On Apr 25, 8:01 pm, greenpoise wrote: > It works! Thanks. Question, now I need to create a controller to > download the files? > I will try to add a few lines to locally remove the file once is > uplo

[web2py] Re: Web2py Upload Function

2010-04-25 Thread greenpoise
Also noticed that it works with txt files. PDF wont make it to the database is there a specific reason for this? On Apr 25, 9:01 pm, greenpoise wrote: > It works! Thanks. Question, now I need to create a controller to > download the files? > I will try to add a few lines to locally remove th

[web2py] Re: Web2py Upload Function

2010-04-25 Thread greenpoise
It works! Thanks. Question, now I need to create a controller to download the files? I will try to add a few lines to locally remove the file once is uploaded. I wanted to try this and perhaps to be able to fully use it in a future. After trying SO MANY CMS systems, I found out that one of the hard

[web2py] Re: Web2py Upload Function

2010-04-25 Thread mdipierro
My bad again. Try this: @auth.requires_login() def list_of_files(): import os path='/upload/Documents' files = os.listdir(path) db.document.scandoc.uploadfolder='/upload/Documents' for filename in files: stream=open(os.path.join(path,filename),'rb') db.document.insert(

[web2py] Re: Web2py Upload Function

2010-04-25 Thread greenpoise
Thanks! you make it look so easy! >From the error message below, it goes through the files but it stops. File "/home/danel/Applications/web2py/applications/madra_v2/ controllers/default.py", line 198, in list_of_files stream=open(filename,'rb') IOError: [Errno 2] No such file or directory: 'E3

[web2py] Re: Web2py Upload Function

2010-04-25 Thread mdipierro
@auth.requires_login() def list_of_files(): import os files = os.listdir('/upload/Documents') db.document.scandoc.uploadfolder='/upload/Documents' for filename in files: stream=open(filename,'rb') db.document.insert(scandoc=db.document.scandoc.store(stream,filename=filenam

[web2py] Re: Web2py Upload Function

2010-04-25 Thread greenpoise
Ok. I have tried all the above but keeps breaking for me. This is what I am trying: 1. Upload files that are already in a folder into the database (without selecting them one by one) 2. Display those files and be able to download them. This is my code: @auth.requires_login() def list_of_files():

[web2py] Re: Web2py Upload Function

2010-04-23 Thread mdipierro
yes, you have to set db.workspace.filefield.uploadefolder='/somewhere/' On Apr 23, 2:40 pm, greenpoise wrote: > Is this possible? to put on db the files of a folder? > > def list_of_files(): >     import os > > storedfiles=db(db.workspace.id>0).select(orderby=db.workspace.droppedfile) >     fi

[web2py] Re: Web2py Upload Function

2010-04-23 Thread greenpoise
Is this possible? to put on db the files of a folder? def list_of_files(): import os storedfiles=db(db.workspace.id>0).select(orderby=db.workspace.droppedfile) files = os.listdir('/home/dan/Docs') for files in files: db.workspace.insert(filefield = db.workspace.droppedfile.st

[web2py] Re: Web2py Upload Function

2010-04-23 Thread greenpoise
is stream part of a module? thanks dan On Apr 22, 4:51 pm, mdipierro wrote: > Most of it is done in the Field.store() method in sql.py. In fact you > can do > > db.mytable.insert(filefield=db.mytable.filefield.store(stream,filename='original_filename.txt')) > > On Apr 22, 3:27 pm, greenpoise

[web2py] Re: Web2py Upload Function

2010-04-22 Thread greenpoise
Perfect. Will try. Thanks again! Dan On Apr 22, 4:51 pm, mdipierro wrote: > Most of it is done in the Field.store() method in sql.py. In fact you > can do > > db.mytable.insert(filefield=db.mytable.filefield.store(stream,filename='ori­ginal_filename.txt')) > > On Apr 22, 3:27 pm, greenpoise wro

[web2py] Re: Web2py Upload Function

2010-04-22 Thread mdipierro
Most of it is done in the Field.store() method in sql.py. In fact you can do db.mytable.insert(filefield=db.mytable.filefield.store(stream,filename='original_filename.txt')) On Apr 22, 3:27 pm, greenpoise wrote: > wow thats rough!! over 3,000 lines of coding.  thanks!!   :-) > > On Apr 22, 4:0

[web2py] Re: Web2py Upload Function

2010-04-22 Thread greenpoise
wow thats rough!! over 3,000 lines of coding. thanks!! :-) On Apr 22, 4:07 pm, Thadeus Burgess wrote: > Take a look at welcome/controllers/default.py->def download > > Andhttp://code.google.com/p/web2py/source/browse/gluon/sqlhtml.py#291 > > Andhttp://code.google.com/p/web2py/source/browse/