Hello all,
a problem occurs when I try to use Ionic Native File Transfer plugin in my app.
For offline support I need an image to be downloaded to the mobile filesystem. Here is a snippet from my code:
const fileTransfer = transfer.create();
Observable.fromPromise(fileTransfer.download(restProvider.getApiUrl() + encodeURI(url), target)).subscribe(fileEntry => {
downloadCompleted.next(fileEntry.toURL());
downloadCompleted.complete();
I wait for the promise to resolve, wait for all download streams to complete and then switch ngIf with an isInitialized event to show the images.
I thought that the promise resolve will trigger as soon as the image was completely downloaded but that seems to be wrong.
*ngIf="(isInitialized$ | async) && campaigns.length === 0"
...
<img src={{getImage(campaign.image)}} alt={{campaign.title}} showOnLoad/>
When I start the app and the images get loaded from a server, after all file transfer promises are resolved, the images will be rendered incomplete (green or gray, sometimes rainbow bars at the bottom of the images). When I refresh the page some seconds later (without triggering a new download), the images are rendered correctly from the file system. Is there an event to listen for, that emits when the image is 100% downloaded? or does somebody know a better plugin to use?
The problem occurs on both platforms, iOS and android.