www.dextsolution.com
DEXTUPLOAD
X5
Product description > Downloading by using the HD application

# Downloading by using the HD application

DEXTUploadX5 supports the ability to download files using the HD application starting from version 2.0.0.0. HD is the collective term for the Windows daemon (HDD) and the Windows application (HDM).

The HD application runs on the user's desktop and performs file download by HTTP communication with the browser. HD application does not install any plug-ins in the browser, even if they are installed.

Setting the hdDownloadURL property in the dextuploadx5-configuration.js file

  The dextuploadx5Configuration is a JavaScript object that contains the component settings. The dextuploadx5Configuration object has an hdDownloadURL property that is used to set the path to the page where the HD application's installer can be downloaded; the property can be omitted (starting in 4.0.0.0) if the default location is used.

      # dextuploadx5-configuraiton.js
      win.dextuploadx5Configuration = {
          // Can be omitted
          hdDownloadURL: location.origin + "/dx5/client/dextuploadx5-hd-download.html"
      }

  If the HD application is not installed, the address set in hdDownloadURL will be opened in a popup. If the installed HD application is a lower version than the DEXTUploadX5 version, a page at the address set in the hdDownloadURL may pop up to download the higher version.

  * The above page is basically a download page provided by the product. It is recommended to use a unique page designed for each site.

  * In case of Windows OS, you must enable it in the User Account Control window when installing HD application.

Registering item to be downloaded

  To register a virtual file, use the addVirtualFile function or the addVirtualFileList function.

  - vindex: The unique key that distinguishes a virtual file. It can be in any format, but it should not be duplicated. (Required field)
  - name: The name of the virtual file. (Required field)
  - size: The size of the virtual file, in bytes. (Required field)
  - lock: If the lock status is true, the file can not be deleted.

      var dx = dx5.get(id);
      // When registering individually
      dx.addVirtualFile({ vindex: "IDX0001", name: "virtual_file.txt", size: 12345 });
      dx.addVirtualFile({ vindex: "IDX0002", name: "virtual_file_lock.txt", size: 45678, lock: true });
      dx.addVirtualFile({ vindex: "IDX0003", name: "cosmos.jpg", size: 195779 });
      // When adding at once
      dx.addVirtualFileList([
        { vindex: "IDX0001", name: "virtual_file.txt", size: 12345 },
        { vindex: "IDX0002", name: "virtual_file_lock.txt", size: 45678, lock: true },
        { vindex: "IDX0003", name: "cosmos.jpg", size: 195779 }
      ]);

  For the virtual file to be downloaded, the url property must be set.

      // It is a virtual file that can not be downloaded because there is no download path information.
      dx.addVirtualFile({ vindex: "IDX0001", name: "virtual_file.txt", size: 12345 });
      // You can download it if you have a download path.
      dx.addVirtualFile({ vindex: "IDX0003", name: "bridge_509147.jpg", size: 509147, url: "http://domain/path/file/attach/bridge_509147.jpg" });
      dx.addVirtualFile({ vindex: "IDX0003", name: "bridge_509147.jpg", size: 509147, url: "http://domain/path/common-download.do?key=FID0001" });

  The value of the downUrl or url property MUST be a web URL that starts with a schema (http, https).

  If the URL contains multilingual and special characters, the target may not be found or the download may fail. (Not necessarily, it may be different by browser type or version.)

  In this case, you can encode multilingual and special characters using encodeURIComponent JavaScript function.

      dx.addVirtualFile({
        vindex: "IDX0003",
        name: "bridge_509147.jpg",
        size: 509147,
        // Encoding
        url: "http://domain/path/file/attach/" + encodeURIComponent("bridge_509147.jpg")
      });

  When downloading a file, HD can download it in pieces. When registering a virtual file, you can use the chunkSize property to specify the size to be split. There is no big impact on the part of individual users, but from the server's point of view it helps to increase responsiveness to requests.

  If you do not specify the chunkSize property or set it to 0, the download will proceed without splitting.

      dx.addVirtualFile({
        vindex: "IDX0003",
        name: "bridge_509147.jpg",
        size: 509147,
        url: "http://domain/path/file/attach/" + encodeURIComponent("bridge_509147.jpg"),
        // 10MB partition size (can only be specified in MB)
        chunkSize: 10
      });

Setting button events

  When downloading using an HD application, the DEXTUploadX5 product does not provide a download button for the item.

  Instead, you need to use a script to link external HTML buttons with component functionality.

      <button type="button" onclick="download('component-id');">Download</button>
      <script>
      function download(id) {
        // Perform to download according to the flag value.
        // AUTO: Download the all virtual file.
        // SELECTED: Download the all selected virtual file.
        // CHECKED: Download the all checked virtual file.
        dx5.get(id).downloadToHD("AUTO");
      }
      </script>

  It also provides automatic binding at component loading time without using complex scripts..

      <button type="button" id="btn-down-auto">Download</button>
      <button type="button" id="btn-down-selected">Download selected</button>
      <button type="button" id="btn-down-checked">Download checked</button>
      <script>
        dx5.create({
          ...,
          // Let the file download function automatically set when the component is created
          btnDownloadToHDAuto: "btn-down-auto",
          btnDownloadToHDSelected: "btn-down-selected",
          btnDownloadToHDChecked: "btn-down-checked"
        });
      </script>

  The automatic binding functionality is very convenient, but it may not be suitable for implementing complex functions.

Server-side processing according to download request

      // If the download target is exposed as a web address
      { vindex: "IDX0003", name: "bridge_509147.jpg", size: 509147, url: "http://domain/path/files/attach/bridge_509147.jpg" }
      // If you do not have the web address you want to download, or if you use a web application to handle the URL hiding process
      { vindex: "IDX0003", name: "bridge_509147.jpg", size: 509147, url: "http://domain/path/files/service/common-download.do?key=FID0001" }

  The following is a case where the service is implemented using DEXTUploadNJ product in Java JSP or Servlet environment.

  You can use the FileDownload class to handle downloads in a given mapping servlet (which can also be a JSP).

      # Server-side
      File target = null;

      String key = request.getParameter("key");
      if (key.equals("FID0001")) target = new File(fileRoot, "bridge_509147.jpg");
      else if (key.equals("FID0002")) target = new File(fileRoot, "beach_239826.jpg");
      else if (key.equals("FID0003")) target = new File(fileRoot, "cosmos (empty) 195779.jpg");
      if (target == null  || target.exists() == false || target.isFile() == false) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND, "Not found files for the key");
        return;
      }
      try {
        // Create a FileDownload object.
        FileDownload dextnj = new FileDownload();
        // Set the encoding to UTF-8.
        response.setCharacterEncoding("UTF-8");
        dextnj.setAllowingWeakRange(true);
        // Download the file as an attachment file.
        dextnj.download(request, response, target);
      } catch (Exception e) {
        throw new ServletException(e);
      }

  The following is an example of implementing a service using the DEXTUploadNJ product in the Java Spring web framework environment.

  You can use the DEXTUploadNJFileDownloadView class in the controller's method mapped to a given request to handle the download.

      # Server-side
      File target = null;

      String fileRoot = request.getSession().getServletContext().getRealPath("/files/attach");
      if (key.equals("FID0001")) target = new File(fileRoot, "bridge_509147.jpg");
      else if (key.equals("FID0002")) target = new File(fileRoot, "beach_239826.jpg");
      else if (key.equals("FID0003")) target = new File(fileRoot, "cosmos (empty) 195779.jpg");

      // Set the encoding to UTF-8.
      response.setCharacterEncoding("UTF-8");

      if (target == null  || target.exists() == false || target.isFile() == false) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND, "Not found files for the key");
        return null;
      } else {
        // You can download the file using the DEXTUploadNJFileDownloadView view class.
        DEXTUploadNJFileDownloadView dextnj = new DEXTUploadNJFileDownloadView(target);
        dextnj.setAllowingWeakRange(true);
        return new ModelAndView(dextnj);
      }

HD Application Screen Description

  When the download button is clicked or the downloadToHD method is called, the HD application is executed as shown below. After the target items are added, download starts immediately.

  If the downloaded item is already downloaded, a green check icon is displayed on the right side. Clicking this icon opens the location where the target was downloaded, and clicking the X icon removes the item from the list.

  If the automatic download option is not specified, the files will be in a waiting state for downloading, and the orange down-arrow (download) icon will be displayed on the right side.

  On the left side of the lower bar, there are buttons for downloading all items, stopping all items and deleting all items, and on the right side of the lower bar there is a button for changing the downloading order of the selected items.

HD application options

  You can adjust the options by clicking on the star icon in the HD application title bar, or by right clicking on it and opening the 'Preferences' window.

  - Download path

    It indicates the path to download files, and can be changed.

  - Activate program when adding item

    When an item is added to the HD application, the HD application appears so you can check it. (Sometimes other programs are preempted and HD applications do not appear at the front.)

  - Auto download starting when new item added

    As soon as HD applications are added, they are ready to download or download them. The default value is checked, but if checked, the user must click the download button to perform the download.

  - Delete temporary fiels when deleting items (Resume function is not supported for the same item)

    Even if the file is removed from the list, HD will continue to download it next time. However, if you check this option, you can start downloading from the beginning by downloading the target item again. (The reason for using this option is because there is a problem with the server and there is a fluctuation in the download target, or there may be a problem with the download operation.) This option is related to the resume action after the item is deleted It does not affect the succession that occurs in other processes.

  - Auto-start items that were being downloaded when adding previous items

    This option allows you to resume a suspended download the next time the program is started, if the program is interrupted (if it is completely terminated using the Exit command) while it is being downloaded. The download target is limited to the item that was being downloaded at the time the program was stopped.

  - File information saving options

    When program execution is interrupted, it points to the item to be restored (included in the list) the next time the program is run again. (If 'Downloading' is unchecked, even if the 'Auto-start items that were being downloaded when adding previous items' option is checked, the download operation will not proceed because there is no target to open.)

Deleting HD application

  - HD applications for Windows can be deleted by selecting DEXTUploadX5 HD from the 'Programs and Features' menu under 'Control Panel'.

HD application restrictions

  - If your login account does not have administrator privileges, HD applications will not start automatically.

    To start the HD application manually, run the 'DEXTUploadX5-HDD.exe' file located in the product installation location.

  - HD applications do not provide the ability to run files directly.

  - Because HD applications do not download files through a browser, they do not share the browser's cookie, session, and authentication information.

  - Web applications using non-secure connections other than localhost cannot communicate with HD. Refer to the 'Communication failure with HD applications according to the Private Network Access specification' section of the 'Known Issues' document.
  - Downloading objects from Amazon S3, NAVER CLOUD PLATFORM Object Storage, and Microsoft Azure Blob Storage is not supported.