API: Manage Local Files

Check to see if a file currently exists in Kiosk Pro's documents folder, as well as move, rename, or delete files as needed.

Requirements

Kiosk Pro Plus and Enterprise

  • Integration of our JavaScript API into your webpage
    • Sample code to run within the app and download for integration into your own project is available here.
    • Best practices for working with the JavaScript API are available here.
  • App Settings
    • Content > JavaScript API > Access JavaScript API = By Import


Triggers via API Functions

Check if File Exists

This function checks whether a file currently exists in Kiosk Pro's Documents folder. If the file is located in a subfolder, the filepath included in the name parameters should be relative to Kiosk Pro's Document root folder (not to the page calling the function).

Format
fileExists(filename,callback);
		
Parameters
  • filename - [string, required] the name of the file to check
  • callback - [string, optional] the name of the callback to be triggered after the function has been executed
Callback format
callback(success);
		
Callback return values success - if defined, the files exists.


Rename or Move File

This function allows you to rename any locally stored file in Kiosk Pro's Documents folder or to move a file to a new location by renaming it with a new filepath. If the file is or will be located in a subfolder, the filepath included in the name parameters should be relative to Kiosk Pro's Document root folder (not to the page calling the function).

Format
kp_FileAPI_renameFile(oldFileName, newFileName, callback)
		
Parameters
  • oldFileName - [string, required] the name of the existing file to rename
  • newFileName - [string, required] the new name of the file
  • callback - [string, optional] the name of the callback to be triggered after the function has been executed
Callback format
callback(success);
		
Callback return values success - if defined, the file was renamed successfully


Delete File

This function deletes a file stored locally in Kiosk Pro's Documents folder. If the file is located in a subfolder, the filepath included in the name parameter should be relative to Kiosk Pro's Document root folder (not to the page calling the function).

Format
deleteFile(filename,callback);
		
Parameters
  • filename - [string, required] the name of the file to delete as a string
  • callback - [string, optional] the name of the callback to be triggered after the function has been executed
Callback format
callback(success);
		
Callback return values success - if defined, the file has been deleted


Deprecated

Return Base64 String from File

Deprecated in version 10.0. As Base64 strings can be very large, running this type of processing on a full-resolution image can result in performance problems when using Kiosk Pro. We continue to support a newer call, kp_PhotoVideo_base64FromScaledPhoto, that supports passing specific pixel dimensions for the resulting Base64 string, allowing you to request the minimum necessary size required for a specific use case.

This function returns the appropriate base64 string for any locally stored image file in Kiosk Pro's Documents folder. This can be useful when your content is hosted remotely, but you require access to a file that is stored locally on the device - for example, if you wanted to create a thumbnail to display on your page or return a text string that can be uploaded to a database.

If the file is located in a subfolder, the filepath included in the name parameters should be relative to Kiosk Pro's Document root folder (not to the page calling the function).

Format
kp_FileAPI_base64FromFile(filename, callback);
		
Parameters
  • filename - [string, required] the name of the image file to convert to a Base64 string
  • callback - [string, optional] the name of the callback to be triggered after the function has been executed
Callback format
callback(base64String, error);
		
Callback return values
  • base64String - the base64 string of the resized image
  • error - if defined, an array of key-value pairs returning the reason for failure

  • Sample Code

    • This sample code relies on the JavaScript APIs built into Kiosk Pro and will not run successfully in other browsers or within our in-app help interface.
    • To run sample code, set the app's homepage to kioskgroup.com/file-management-api
    • To download a .zip of sample code, click here.

    Change Log

    • Added in version 1.1. Ability to return Base64 string from file added in version 7.5 & deprecated in version 10.0

    Still stuck? How can we help? How can we help?