Intro
Working with locally stored files is essential part of any digital signage application. It allows you to display content even if the device loses its connection to the internet or your server.
In general, there are two philosophical approaches for file management - File system and File Cache.
File System approach brings flexibility of complete file management similar to what we know from PC/MAC. Including folders management, copy, move and complex file paths. It's more complex and more powerful.
File Cache approach is abstracting the file system, providing flat structure of unique files and basic operations like save, load and delete. It's much easier to work with yet it has its own limits.
Both approaches can be combined within the Applet code. Below are described frequent use cases and differences you need to know prior development.
How to work with external storage
File System API
- using File System API you can select whether you want to save/load files from internal or removable storage
- BEWARE: if you have USB flash drive full of files and you perform delete() operation, you will delete not only files downloaded by the API but all the files on the USB.
Cache
- Cache is automatically selecting the storage with the largest available space
How can I get available space in the Applet
This information is available in the File System API, where you can get available storage for both - internal and external (USB) storage.
How often is the Cache cleared
Cache
- Cache is never automatically cleared or expired
- Applet code is responsible for deciding which files should be removed and which should stay saved
- You can perform Applet Reload (via Box or REST API) to wipe out all files stored by Cache API
How are Power Actions - Reboot, Refresh, Restart, Reload - affecting files saved internally
- Reboot, Restart and Applet Refresh do NOT anyhow affect saved files. Files that were saved into the internal storage remains persistently there.
- Applet Reload wipes out all files saved by Cache API
- Applet Reload does NOT affect files saved by File System API unless you save them to
/data
folder which is reserved for Cache API files