I am planning a part of a project and would like to ask for some advice.
The project up to now is purely Ionic 4 & Capacitor based (no Cordova).
What I would like to accomplish is to:
Check if the file exists on the local device
If it does not exist, then download the user’s profile picture from a specific server URL and store it on the local device for use
Display the image on their profile page.
What I can see is that the native File Transfer (Cordova) method might be an option, however, I would actually like to keep the project away from Cordova, and just stick with Capacitor, but from what I can see in the FileSystem docs of Capacitor, it does not have the same functionality?
Firstly, am I wrong in thinking this way?
Then secondly what is the best way for me to accomplish my set-out goal?
Not a great one, as the underlying plugin has been sunset. If you’re talking about small avatars, I would consider dispensing with dealing with the native filesystem entirely and just store base64 images and/or data-urls in Ionic Storage.
Thank you very much.
Currently, I am using this storage for the URL, but even though small, did not want to have a download each time the user views their profile.
I never thought about saving the base64 string in Ionic Storage. Good idea, thank you.
What are the limitations of Ionic Storage?
Am I then also correct in assuming that should there be a need to download larger files in the future, XMLHttpRequest would be the route to go?
It uses various underlying drivers, and you can control which ones. Aside from the limitations of the drivers, there isn’t any sort of query language like SQL, but for storing avatars, I wouldn’t think you would need one. You could store one avatar per key, using the username as the key, or put all of them into a single array if they don’t change frequently.
Yes, but you shouldn’t have to think of it that way. Just use Angular’s HttpClient. Under the hood, it turns into an XHR, but you as an app author don’t have to care about things at that deep of a level.