Class BinaryFileServlet.DownloadTicket

java.lang.Object
com.jalios.jcms.servlet.BinaryFileServlet.DownloadTicket
All Implemented Interfaces:
Serializable
Enclosing class:
BinaryFileServlet

public static class BinaryFileServlet.DownloadTicket extends Object implements Serializable
See Also:
  • Constructor Details

    • DownloadTicket

      public DownloadTicket(File file)
      Builds a new download ticket for the specified file.
      Parameters:
      file - the file to send required.
    • DownloadTicket

      public DownloadTicket(File file, String contentType)
      Builds a new download ticket for the specified file.
      Parameters:
      file - the file to send required.
      contentType - the content type to use (default is application/octet-stream)
    • DownloadTicket

      public DownloadTicket(File file, String contentType, String filename)
      Builds a new download ticket for the specified file.
      Parameters:
      file - the file to send. required.
      contentType - the content type to use (default is application/octet-stream)
      filename - the filename to be displayed in the browser (content disposition/attachement), use alphanumeric or dash, do not use special characters.
    • DownloadTicket

      public DownloadTicket(File file, String contentType, String filename, boolean forceDownload)
      Builds a new download ticket for the specified file.
      Parameters:
      file - the file to send. required.
      contentType - the content type to use (default is application/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

      public void setContentType(String contentType)
      Set the content type to use for this download.

      Default is application/octet-stream.

      Parameters:
      contentType - a content type such as "image/jpeg"
    • setFilename

      public void setFilename(String filename)
      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 as my-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 HttpServletRequest
      response - the response in which to write redirect headers
      Throws:
      IOException - the IO exception
    • toString

      public String toString()
      Overrides:
      toString in class Object