java - Rest service : issues to download multiple Zip files using : ResponseBuilder -



implemented rest service donwload files directory.
**there rest service : no problem here **

@get @path("/download") @produces("application/zip") public response downloadzippedfile() {          file file = new  file("c:/users/desktop/files/201707111513.zip");         responsebuilder responsebuilder = response.ok((object) file);         responsebuilder.header("content-disposition", "attachment;  filename=\"myjerseyzipfile.zip\"");         return responsebuilder.build(); } 

résult ==> can download 201707111513.zip browser.
-------------------------------------------------
now, trying download multiple .zip files. it causes issues
there 2nd rest service : main problem

@get @path("/download") @produces("application/zip") public response downloadzippedfile() {     arraylist<string> pdfinputlistfiles = new arraylist<>();      pdfinputlistfiles.add("c:/users/desktop/files/201707111513.zip");     pdfinputlistfiles.add("c:/users/desktop/files/201707111514.zip");     pdfinputlistfiles.add("c:/users/desktop/files/201707111515.zip");       // print every file in every pdfinputlistfiles      (string myfile : pdfinputlistfiles) {          file file = new file(myfile);         responsebuilder responsebuilder = response.ok((object) file);         responsebuilder.header("content-disposition", "attachment; filename=\"myjerseyzipfile.zip\"");         return responsebuilder.build();      }     return null; } 

résult ==> can download first file 201707111513.zip.
, it's normale cause of return responsebuilder.build() line in end of loop.
-------------------------------------------------
now, tryin :

@get @path("/download") @produces("application/zip") public response downloadzippedfile() {     arraylist<string> pdfinputlistfiles = new arraylist<>();      pdfinputlistfiles.add("c:/users/desktop/files/201707111513.zip");     pdfinputlistfiles.add("c:/users/desktop/files/201707111514.zip");     pdfinputlistfiles.add("c:/users/desktop/files/201707111515.zip");       // print every file in every pdfinputlistfiles      (string myfile : pdfinputlistfiles) {          getfile(myfile);      }     return null; }  public response getfile(string str) {     // response response = null;     file file = new file(str);     responsebuilder responsebuilder = response.ok((object) file);     responsebuilder.header("content-disposition", "attachment; filename=\"myjerseyzipfile.zip\"");     return responsebuilder.build(); } 

résult ==> no download happen, can't understand why calling getfile method doesn't return downloaded file.
** need download evry file in list, in other words have multiple paths , need download files.
can help, or suggest alternative solution !
thank you


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -