Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature currently requires accessing the site using the built-in Safari browser.
@Controller
public class AjaxDocumentDownloadController
{
@RequestMapping(value = "/master/download", method = RequestMethod.GET)
public void download( @RequestParam(value = "folderPath", required = true) String folderPath, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
response.setContentType("application/pdf");
response.setHeader("Content-Description", "File Transfer");
response.setHeader("Content-Disposition", "attachment;filename=downloadfilename.pdf");
StringBuffer sb = new StringBuffer("whatever string you like");
InputStream in = new ByteArrayInputStream(sb.toString().getBytes("UTF-8"));
ServletOutputStream out = response.getOutputStream();
byte[] outputByte = new byte[24];
// copy binary connect to output stream
while (in.read(outputByte, 0, 24) != -1)
{
out.write(outputByte, 0, 24);
}
in.close();
out.flush();
out.close();
}
}
Wieso "downloadfenster vom Browser" ?Der String wird zwar als Antwort zurückgelifert jedoch schreibt er ihn mir nicht in die Datei und öffnet auch nicht das downloadfenster vom Browser.
Also gleichzeitig Lesen und Schrieben über die gleiche Variable wird sicherlich problematisch sein.Code:response.setContentType("application/pdf"); response.setHeader("Content-Description", "File Transfer"); response.setHeader("Content-Disposition", "attachment;filename=downloadfilename.pdf"); StringBuffer sb = new StringBuffer("whatever string you like"); InputStream in = new ByteArrayInputStream(sb.toString().getBytes("UTF-8")); ServletOutputStream out = response.getOutputStream(); byte[] outputByte = new byte[24]; // copy binary connect to output stream while (in.read(outputByte, 0, 24) != -1) { out.write(outputByte, 0, 24); } in.close(); out.flush(); out.close();
@Controller
public class AjaxDocumentDownloadController
{
@RequestMapping(value = "/master/download", method = RequestMethod.GET)
public void download( @RequestParam(value = "folderPath", required = true) String folderPath, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
response.setContentType("application/pdf");
response.setHeader("Content-Description", "File Transfer");
response.setHeader("Content-Disposition", "attachment;filename=downloadfilename.pdf");
StringBuffer sb = new StringBuffer("whatever string you like");
InputStream in = new ByteArrayInputStream(sb.toString().getBytes("UTF-8"));
ServletOutputStream out = response.getOutputStream();
byte[] outputByte = new byte[24];
// copy binary connect to output stream
while (in.read(outputByte, 0, 24) != -1)
{
out.write(outputByte, 0, 24);
}
in.close();
out.flush();
out.close();
}
}