File download via endpoint

60 views
Skip to first unread message

scho

unread,
Nov 6, 2012, 8:27:20 AM11/6/12
to net...@googlegroups.com
Hi everyone,

I'm trying to accomplish a file download via a netzke endpoint/ajax. E.g. I want to export the data of a grid panel into excel.

In my opinion, the 'classic/none-ajax' way would be to create a controller and do all the rendering/exporting there. So a simple button that changes window.location would do the trick.

On the other hand, that would duplicate a lot of code, since I already have a lot of things in my component, that I could use (e.g. get_data/get_records).

I think, doing it via an endpoint would be much nicer & cleaner. So, has anyone done such a thing or could share some ideas?

cheers,
Georg

nomadcoder

unread,
Nov 6, 2012, 10:56:52 AM11/6/12
to net...@googlegroups.com
Georg,

What about doing the following in an endpoint: 1) generate the file, 2) store it in a place accessible by HTTP server, 3) return the file's URL from the endpoint, 4) setting window.location to that URL?

--
NC
@nomadcoder
author of @netzke



6 Nov 2012 21:27
--
You received this message because you are subscribed to the Google Groups "Netzke" group.
To post to this group, send email to net...@googlegroups.com.
To unsubscribe from this group, send email to netzke+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/netzke/-/sd1ae8CiiDUJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

scho

unread,
Nov 6, 2012, 11:12:56 AM11/6/12
to net...@googlegroups.com
Hei Denis,

I thought about something similar as well, but the file must not be public accessible. 
I could 'hide' it somehow by random filename/dirname, but I think I'll create a user attachment model and I'll store it there.
Then a user could also access all his exported files. This could be a nice feature for the future :)

I also found some strange hacks with iframes, etc. but I don't think this would end up in a nice & clear solution.

Thanks for your thoughts!
Reply all
Reply to author
Forward
0 new messages