开发者

How to indicate the file name for saving to the browser from a REST service in Jersey?

i am trying开发者_StackOverflow社区 to have a REST service return a zip file from the local harddrive . Following is what i am doing ,

@Path("/interface3/{Ent_id}/{esf_app_id}/{esf_app_ver}")
public class Interface3Mock {

    // This method is called if TEXT_PLAIN is request
    @GET
    @Produces("application/zip")
    public Response  callInterface3_text(
            @PathParam("Ent_id") Integer entitlement_id,
            @PathParam("eapp_id") String eapp_id,
            @PathParam("eapp_ver") String eapp_ver) {
        File f = new File("D:\\Documentation\\Documentation.zip");

        String mt = new MimetypesFileTypeMap().getContentType(f);

        return Response.ok(f, mt).build();

    }
}

Now when i use the browser ie. Internet Explorer and key in the url http://localhost:9788/mockRESTServer/rest/interface3/123456/k123/l345 i see a file download dialog that says "Do you want to save the file l345`.

i want it to ask me for the zip download ie. D:\\Documentation\\Documentation.zip. But somehow it takes up the last parameter in the request URL.


return Response.ok(f, mt)
        .header("Content-Disposition", "attachment; filename=Documentation.zip")
        .build();

See How to set response header in JAX-RS so that user sees download popup for Excel?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜