I this how to write client to download the address?
CodePudding user response:
One way to writeprivate void downloadFile (HttpServletResponse response, the File File) {
/* set file ContentType type, such Settings, automatically download file types */
The response. SetContentType (" multipart/form - data ");
/* set file header: the last parameter is set to download the file name */
response.setHeader("Content-Disposition", "attachment; Filename="+ file. The getName ());
Try (
InputStream ins=new FileInputStream (file);
OutputStream OS=response. GetOutputStream ()
) {
Byte [] b=new byte [1024].
int len;
While ((len=ins. Read (b)) & gt; 0 {
OS. Write (b, 0, len);
}
} the catch (IOException ioe) {
Ioe. PrintStackTrace ();
}
}
This is ok
CodePudding user response:
No, I this way the client can only accept a url to download the PDF, others write good call, is there any way to my files are generated to his project, or the path of the PDF on my side can let him directly download?CodePudding user response: