gwt - Download file using Jersey and RestyGWT -


hi possible download file server passing list parameter

with restygwt , jersey 1.7?

on server side have following web service

@post @produces(mediatype.application_octet_stream) @path("/download") public response downloadfiles(@context httpservletresponse response, list<fileinfo> files) {     zipfile zip = null;      string uuid = uuid.randomuuid().tostring();     response.setheader("content-disposition", "attachment; filename="             + uuid + ".zip");     try {         zip = new zipfile(response.getoutputstream());         file f = new file(configurationloader.getrealpath("/logo.png"));         zip.addfile(f, "");         zip.getoutputstream().flush();         zip.getoutputstream().close();     } catch (exception e) {         e.printstacktrace();     }     return null; } 

when type in browser localhost:8080/url/download works how can download file resty gwt or via window.open()?

i want use post not can pass list of serializable object e.g: list files.

i tried on client side restygwt:

@post @produces("application/zip") @path("/download") public void downloadfiles(list<fileinfo> files, methodcallback<response> response);  private static final resource resource = new resource(                 gwt.gethostpagebaseurl() + "rest/files");          public static final filerestservice get() {             if (instance == null) {                 instance = gwt.create(filerestservice.class);                 ((restserviceproxy) instance).setresource(resource);             }             return instance;         } 

but doesnt work , cant find examples downloading files in restygwt

in general(*) cannot use ajax download files, have use window.open() or iframe ask user save file as.

take response in query: window.open in gwt not open correctly in call function

of course using iframes cannot use post, code loop ask different file each time last iframe loaded. user asked many times files download.

you use formpanel though, add hidden parameters , post server. formpanel displays response in hidden iframe, setting appropriate headers (content-type content-disposition) download file , ask user save as. zip set of files user can save or open content since more os have utilities visualize compressed files.

(*) using xhr download files, need way process content , display user. it's used text files html, txt, xml, etc. take html5 api receive , process binary data. cannot create files in user's filesystem though.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -