A zip file is written in 'download_data' and nothing happens upon 
returning. 


Please indicate what is missing in the following ajax call and / or 
controller function to spawn the zip file download.


jQuery.ajax({method:'get',url:'{{=URL('download_data')}}',

                data:fileIDs,

                success: function(){}


                });


__


def download_data():

    vars = request.get_vars

    fileIDs = vars.values()

    import zipfile

    import cStringIO

    import contenttype as c

    

    zf = zipfile.ZipFile('data download.zip', mode='w')

    try:

        for file_id in fileIDs:

            file = db.files[file_id].file

            fileLoc = db.files.file.retrieve_file_properties(file)['path'] 
+ '/' + file

            displayName = db.files[file_id].file_name

            zf.write(fileLoc, displayName)

    

    finally:

        zf.close()


    s=cStringIO.StringIO() 

     

    zipfile = open('data download.zip','r')

    s.write(zipfile.read())  

    response.headers['Content-Type'] = c.contenttype(filename)

    response.headers['Content-Disposition'] = "attachment; filename=%s" % 
filename  

    return s.getvalue()

-- 
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 the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to