gluonhq / attach

GNU General Public License v3.0
48 stars 26 forks source link

How to access to Cache Storage files on different Operating Systems? #366

Open LordTylus opened 1 year ago

LordTylus commented 1 year ago

Hello there,

I am currently working in a small app that downloads some amount of Data from the internet and stores it locally for on demand use.

These data are non-essential for the apps basic usage and can be re-downloaded whenever they become relevant to the user again. Also they are only rarely altered on the server. In most use cases, them being outdated doesn't impact the users experience either.

For this purpose, I would like to store the files inside the Apps cache directory, so the user has an easy way of cleaning them up when needed, or in case of iOS, the system can do so when it runs low on storage space.

It is my understanding, that in both supported mobile operating systems there is a designated location for caches. On Android I would get the cacheFiles() from the Application Context which may point to: /data/user/0/your.package.name/cache instead of /data/user/0/your.package.name/files

See: https://developer.android.com/training/data-storage/app-specific

and on iOS it may point to ~/Library/Caches instead of ~/Documents

See: https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html

On Windows, I would probably just like to drop them into the Users Local Temp file which is located in %LOCALAPPDATA%\Temp instead of for example the installation directory or the Users Documents or Roaming directories.

I have examined the StorageService which grants me access to the privateStorage, but I am not entirely certain how to navigate into the respective cache directory, without checking for the Operating System first and then manually navigating to it.

And according to the CacheService documentation it only grants in access to an inmemory cache which unfortunately doesn't satisfy the requirements.

Could someone be so kind and point me to the right direction? I Really wouldn't want