java - Download list of File Using RESTful Web Services with JAX-RS -
taken from, http://www.concretepage.com/webservices/download-file-using-restful-web-services-jax-rs, here code download file jax-rs rest service
@path("/restwb") public class fileresource { @get @path("/download/{fname}/{ext}") @produces(mediatype.application_octet_stream) public response downloadfile(@pathparam("fname") string filename,@pathparam("ext") string fileext){ file file = new file("c:/temp/"+filename+"."+fileext); responsebuilder rb = response.ok(file); rb.header("content-disposition", "attachment; filename=" + file.getname()); response response = rb.build(); return response; } }
my question should response in order download list of file objects (arraylist)?
can write:
list<file> lfiles = new arraylist<file>(); ... responsebuilder rb = response.ok(lfiles);
you can not download multiple files in same request. if need download multiple files have create archive download archived file.
this because raw bytes of file sent in http response, , http headers used how translate content can set 1 set of headers http response.
Comments
Post a Comment