Package org.zkoss.zkmax.au.http

## Class AuDownloader

- java.lang.Object
- - org.zkoss.zkmax.au.http.AuDownloader

- All Implemented Interfaces:
    `AuExtension`

      public class AuDownloader
      extends java.lang.Object
      implements AuExtension

  The AU processor to handle the resumable download.

  Available in ZK EE

  Since:
    3.5.0
  Author:
    tomyeh
  See Also:
    `Filedownload`

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `destroy()` | Destroys the AU extension.
    `static java.lang.String` | `getDownloadURI​(java.io.File file, java.lang.String contentType, java.lang.String data)` | Returns the download URI of the specified file.
    `static java.lang.String` | `getDownloadURI​(java.lang.String path, java.lang.String contentType, java.lang.String data)` | Returns the download URI of the specified file.
    `static java.lang.String` | `getDownloadURI​(java.net.URL url, java.lang.String contentType, java.lang.String data)` | Returns the download URI of the specified file.
    `void` | `init​(DHtmlUpdateServlet servlet)` | Initializes the AU extension.
    `static void` | `init​(WebApp wapp)` | Initializes the downloader.
    `void` | `service​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String pi)` | Called by ZK to process the AU request.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.zkoss.zk.au.http.AuExtension

      `charsetSetup`

- - ### Method Detail

    - #### init

          public static void init​(WebApp wapp)
                           throws javax.servlet.ServletException

      Initializes the downloader.
      Throws:
        `javax.servlet.ServletException`

    - #### init

          public void init​(DHtmlUpdateServlet servlet)

      Description copied from interface: `AuExtension`
      Initializes the AU extension. It is called when an extension is added to `DHtmlUpdateServlet`.
      Specified by:
        `init` in interface `AuExtension`

    - #### destroy

          public void destroy()

      Description copied from interface: `AuExtension`
      Destroys the AU extension. It is called when an extension is removed from `DHtmlUpdateServlet`, or when `DHtmlUpdateServlet` is being destroyed.
      Specified by:
        `destroy` in interface `AuExtension`

    - #### getDownloadURI

          public static java.lang.String getDownloadURI​(java.io.File file,
                                                        java.lang.String contentType,
                                                        java.lang.String data)

      Returns the download URI of the specified file.

    - #### getDownloadURI

          public static java.lang.String getDownloadURI​(java.net.URL url,
                                                        java.lang.String contentType,
                                                        java.lang.String data)

      Returns the download URI of the specified file.

    - #### getDownloadURI

          public static java.lang.String getDownloadURI​(java.lang.String path,
                                                        java.lang.String contentType,
                                                        java.lang.String data)

      Returns the download URI of the specified file.
      Parameters:
        `path` - the path to access the resource of the Web application. In other words, it is URI of ServletContext. Since 3.6.1: if the path is relative, `Desktop.getCurrentDirectory()` is assumed.

    - #### service

          public void service​(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response,
                              java.lang.String pi)
                       throws javax.servlet.ServletException,
                              java.io.IOException

      Description copied from interface: `AuExtension`
      Called by ZK to process the AU request.

      To retrieve the http session, use HttpServletRequest.getSession(). To retrieve the ZK session, use `Sessions.getCurrent(boolean)`.

      Specified by:
        `service` in interface `AuExtension`
      Parameters:
        `request` - the request (never null).
        `response` - the response (never null).
        `pi` - the path info. It includes the prefix when the Au processor is associated (see `DHtmlUpdateServlet.addAuExtension(org.zkoss.zk.ui.WebApp, java.lang.String, org.zkoss.zk.au.http.AuExtension)`. For example, if an AU processor is associated with "/upload", then pi must start with "/upload". Note: it might end with other string depending on the URI you generated to the client.
      Throws:
        `javax.servlet.ServletException`
        `java.io.IOException`