Multiple file download

124 views
Skip to first unread message

sasogeek

unread,
Apr 11, 2015, 7:47:19 AM4/11/15
to web...@googlegroups.com
Is there a way I could download all the files in a db or loop through a db selection and download all associated files via maybe just a click on a link?

Louis Amon

unread,
Apr 11, 2015, 8:21:03 AM4/11/15
to web...@googlegroups.com
I think you'd have to loop through a selection and use retrieve() (http://pydal.readthedocs.org/en/latest/index.html?highlight=retrieve#pydal.objects.Field.retrieve)

If you need a one-click download then perhaps you could zip all the files using the zip library (or gzip or whatever compression you want to use ^^)

sasogeek

unread,
Apr 11, 2015, 2:43:47 PM4/11/15
to web...@googlegroups.com
I zipped the files and saved it in a folder...but how do I download it now? using the the download function doesn't work...

sasogeek

unread,
Apr 11, 2015, 8:55:35 PM4/11/15
to web...@googlegroups.com
I managed to get it working. I looked up the download method in the Response class and apparently it's looking for a table name and field in the file name. I added that structure [table.field.] to my zipped file name [table.field.zipfile_name.zip] and passed it to the download as an argument in URL() and now it works. it zips the file, saves it, then downloads it, Now the next thing I want to do is delete the saved zip file from inside my app once it has been downloaded.

Manuele Pesenti

unread,
Apr 13, 2015, 2:40:58 AM4/13/15
to web...@googlegroups.com
Il 12/04/15 02:55, 'sasogeek' via web2py-users ha scritto:
> I managed to get it working. I looked up the download method in the
> Response class and apparently it's looking for a table name and field
> in the file name. I added that structure [table.field.] to my zipped
> file name [table.field.zipfile_name.zip] and passed it to the download
> as an argument in URL() and now it works. it zips the file, saves it,
> then downloads it, Now the next thing I want to do is delete the saved
> zip file from inside my app once it has been downloaded.
A solution could be to use the scheduler to periodically clean your fs
from zip files older than a reasonable amount of time...

M.

Louis Amon

unread,
Apr 13, 2015, 2:48:03 AM4/13/15
to web...@googlegroups.com
Alternatively, you could also use a tempfile : https://docs.python.org/2/library/tempfile.html

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/Oo2EnS0qpHo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages