Package com.jalios.jcms.servlet
Class BinaryFileServlet.DownloadTicket
java.lang.Object
com.jalios.jcms.servlet.BinaryFileServlet.DownloadTicket
- All Implemented Interfaces:
Serializable
- Enclosing class:
BinaryFileServlet
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDownloadTicket(File file) Builds a new download ticket for the specified file.DownloadTicket(File file, String contentType) Builds a new download ticket for the specified file.DownloadTicket(File file, String contentType, String filename) Builds a new download ticket for the specified file.DownloadTicket(File file, String contentType, String filename, boolean forceDownload) Builds a new download ticket for the specified file. -
Method Summary
Modifier and TypeMethodDescriptionvoidsendToDownloadUrl(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Redirect current request to the download URL of the file specified by this ticket.voidsetContentType(String contentType) Set the content type to use for this download.voidsetDeleteFileAfterDelivery(boolean deleteFileAfterDelivery) Set whether the file should be deleted after the delivery to the client.voidsetFilename(String filename) Set the filename to be displayed in the browser (content disposition/attachement)voidsetUsePragmaNoCache(boolean usePragmaNoCache) Set whether to use HTTP header "Pragma", "no-cache".toString()
-
Constructor Details
-
DownloadTicket
Builds a new download ticket for the specified file.- Parameters:
file- the file to send required.
-
DownloadTicket
Builds a new download ticket for the specified file.- Parameters:
file- the file to send required.contentType- the content type to use (default isapplication/octet-stream)
-
DownloadTicket
Builds a new download ticket for the specified file.- Parameters:
file- the file to send. required.contentType- the content type to use (default isapplication/octet-stream)filename- the filename to be displayed in the browser (content disposition/attachement), use alphanumeric or dash, do not use special characters.
-
DownloadTicket
Builds a new download ticket for the specified file.- Parameters:
file- the file to send. required.contentType- the content type to use (default isapplication/octet-stream)filename- the filename to be displayed in the browser (content-disposition), use alphanumeric or dash, do not use special characters.forceDownload- if true force the download (ie add attachement, in content-disposition header)
-
-
Method Details
-
setContentType
Set the content type to use for this download.Default is
application/octet-stream.- Parameters:
contentType- a content type such as "image/jpeg"
-
setFilename
Set the filename to be displayed in the browser (content disposition/attachement)Default value is null (no filename is sent to browser).
- Parameters:
filename- a filename such asmy-file.csv, use alphanumeric or dash, do not use special characters. or null to skip.
-
setUsePragmaNoCache
public void setUsePragmaNoCache(boolean usePragmaNoCache) Set whether to use HTTP header "Pragma", "no-cache".Default is
false.- Parameters:
usePragmaNoCache- true to use pragma/nocache header, false otherwise.
-
setDeleteFileAfterDelivery
public void setDeleteFileAfterDelivery(boolean deleteFileAfterDelivery) Set whether the file should be deleted after the delivery to the client.Default is
false.- Parameters:
deleteFileAfterDelivery- true to delete file after delivery, false to leave file as is.
-
sendToDownloadUrl
public void sendToDownloadUrl(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException Redirect current request to the download URL of the file specified by this ticket.- Parameters:
request- current HttpServletRequestresponse- the response in which to write redirect headers- Throws:
IOException- the IO exception
-
toString
-