@Security.Authenticated(Secured.class) public static Result download() { User user = getCurrentUser(); if (!user.isAdmin) return redirect(routes.Application.contacts()); String filename = PoiExcelFileReader.writeFile(Contact.all()); response().setContentType("application/x-download"); String headerName = "Content-disposition"; String headerValue = "attachment; filename=" + filename; response().setHeader(headerName, headerValue); return ok(new File(filename)); // return redirect(routes.Application.contacts()); }