0

File Download

  • updated 9 mths ago

Description

The download part is located in form nodes and it allows application end users to download specified files to their file system from a LogicNets-based application. This part is often used in conjunction with the file upload part.

Use

This part is located in the general form nodes for general applications and in form-part nodes for applications built using the Assessment Framework. It allows the application developer to provide a list of files in a collection, directory path, or data table for application users to download. Users can download the selected file or files to a local system or open the file in a new browser if the browser supports that file type.

LogicNets accepts all file types for download; however, the files will only open in the browser if the browser allows that file type.

Tips & Tricks

Often an application will have BOTH the file upload and file download parts included, so a user can upload file(s) and the same (or different) user can see what has been uploaded, and choose to download if required. In this case, it is important to match the parameters in both parts. 

  • When using Source = Directory, match Storage Location and Sub Folder.
  • When checking Unique File Name in the file upload, and downloading by file, select the correct data object name containing the new filename/path for the download source. Run your project in TEST and click on the data tab to search for/find the data object name.

Editor Fields

When adding a file download option to an application, the application developer uses the following fields.

Field Name Description/Use Type/Options Optional/Mandatory

HTML enabled
(v8+)

When this is enabled you can put HTML formatting in the Question caption, which means the system will display HTML tags in the text in the caption editor as they would appear in a browser. The editor browser provides limited HTML editing options for text formatting. You can toggle the HTML-enabled button on and off to alternate between seeing and editing tags and displaying them as they will appear. Yes | No Optional
Question This field should contain any text you want to display to the user. Text Optional
Options These are the download options.
  • Collection: With this option selected, you can specify the name of a collection that contains the list of files for download. Each item in the collection should have the following fields:
    • filepath: This is the physical location of the file.
    • caption: This is the caption that the system should display on the list. But also the caption will be the name of the downloaded file.
    • filetype: This is the type of the file.
    • time_stamp [optional]: This is the time stamp (last modified date) of the file.
    • content [optional]: It is possible to directly set the content of the file in this field
    • encoding [optional]: If the content of the file is encoded as base64, you can set the encoding to 'base64'.

      Example collection:
      - my_collection.filepath = “C:\new_file4.html”
      - my_collection.caption = “myfile”
      - my_collection.filetype = “txt”

      Note: If you point the download part to a file location containing too many files, the application may stop responding and will display a blank page. If that happens, reduce the amount of files located in the folder and try again. There is not an exact number of files that can be located in the file folder, as it can vary based on the capacity of each device.
  • Directory: You can specify a path to a storage location on the server from which the files can be downloaded. If you click 'with subfolders' option, the system also lists the files in the subfolders.
  • File: You can specify a filename that is made available to download. The downloaded filename can be different to the source file (e.g. add $(now) to the filename for it to be timestamped at the time of download, filename = download_YYYYMMDD.HHMMSS.abc)
  • Data Object: You can specify a data object that contains text or base64-encoded data to be downloaded. Enter the data object name in the source (data object) field.
  • Datasource: You can specify the name of the data source (database and table) that contains the downloadable content. If you leave the database field empty the system assumes the table is within the package itself.

    The table should have the following columns:
    • caption: This is the caption the system will display on the list.
    • content: This is the content of the file.
    • filetype: This is the type of the file.
    • encoding: base64 or empty.

      You can create a table in the workspace in the resources\data folder or in an external database using SQL. An example SQL statement is CREATE TABLE [NAME OF THE TABLE] (id Integer PRIMARY KEY AUTOINCREMENT UNIQUE NOT NULL, caption Text, content BLOB, filetype Text, encoding TEXT);. If you create a table in an external database, you must import the table definition into the workspace using the Import definition from existing table function in the resources\data folder of your project.
Dropdown Menu Mandatory
Directory This is the storage location of the files for download by the download control. Text Mandatory
Sub folder

This option becomes available when the storage location is set to '(local) \appdata' or '(local) \temp'. It allows you to specify the subfolder within the given directory to which the file(s) must be uploaded.

If the sub folder was specified in the File Upload part, then match the parameter here to be able to see uploaded files.

Text Optional
(whitelisted) Path This option becomes available when the storage location is set to 'external directory'. It allows you to specify the path to the external directory. NOTE: External directories must be whitelisted in the settings.cfg file before the file can be downloaded. Text Mandatory
Storage location This is the storage location of the file(s):
  • (local) \appdata: This is the \appdata folder in the company-dat folder of your LogicNets installation.
  • (local) \temp: This is the \temp folder in your company-dat folder of your LogicNets installation. Note: The \temp folder will be cleared at set intervals so this location should be considered temporary storage.
  • External directory: This is a custom location outside the standard \appdata and \temp folders.
NOTE: External directories must be whitelisted to allow files to be downloaded (or uploaded). See the Whitelisting Directories article for more information.
Dropdown Menu Mandatory
File type filter This field allows you to specify file type filters separated by a colon; for example, “.txt, .css, .html”. In this case, the system will only display files of type txt, css, or html. If the application developer does not set a filter type the system displays all available files. Text (case sensitive) Optional
Action This parameter specifies the possible actions for the user:
  • Download: The item can be downloaded.
  • Open: The item can only be opened in a new browser tab.
  • Download and Open: The item can both be downloaded or opened in a new browser tab.
Dropdown Menu Mandatory
Show stamp If you check this checkbox the system shows an additional column for the time stamps of the files in the downloaded result. Checkbox Optional
Show delete button If you check this checkbox the system will display a file delete button in the actions list. This allows users to remove a file from the list. Checkbox Optional
Submit after delete If you click this checkbox the system will step the logicnet forward when the user clicks the delete button. This would allow you to display the outcome of the delete action, for example. Checkbox Optional
Deleted file (data object) This option is only available if 'show delete button' is activated. When a user deletes a file, the system saves the following information on the provided location:
  • filepath: This is the physical location of the file.
  • filename: This is the caption that the system displayed on the list.
  • filetype: This is the file type.
  • delete_at: This is the time stamp of the deletion.
Text Optional
Custom headers If you check this box the system displays your custom text instead of the predefined table headers. You enter the custom text in the following fields. Checkbox Optional
Custom header: Caption This option is only available if 'Custom headers' is activated. This field holds the text the system will display as the header instead of the default value 'Caption'. Text Optional
Custom header: Time stamp This option is only available if 'Custom headers' is activated. This field holds the text the system will display instead of the default value 'Time stamp'. Text Optional
Custom header: Actions This option is only available if 'Custom headers' is activated. This field holds the text the system will display instead of the default value 'Actions'. Text Optional
Directly start download If you check this option the system downloads the item specified in the ItemId field. The ItemId points to the item in the collection (index) or the Id of the record in the database table. The system will not display the download control. Checkbox Optional

Styling

The file upload and download parts contain the standard form part template in the Assessment Framework, and in that use case are presented on screen in the same style as regular form parts for radiolists and checklists. Additionally, its is possible to use the part CSS class in the style tab to assign additional CSS declarations.

In LogicNets versions up to and including v7.3, to override the default styling of the table with all the files you must override the file_download_table class in your custom CSS file. For example, .file_download_table { font-size:16px; }

Hiding an Empty Download Table

The download part will display on screen regardless of the number of files it presents (with no files in the specified location/directories, the titles will still appear. You can hide the table with the following CSS (which hides the table unless there is a second row - the first file listed)

file_download_table {display:none}
file_download_table:has(tr:nth-child(2)) {display:inline;}

Note there is a different solution for Firefox browsers outlined here – you should add this if you anticipate users browsing with Firefox.

https://developer.mozilla.org/en-US/docs/Web/CSS/:has

Example

Please download and import the following example project to your workspace.

Reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
Like Follow
  • 1 yr agoLast active
  • 73Views
  • 3 Following

Home