Get image from file.dataDirectory returns 404 not found (after normalizeURL)


#1

I’m trying to show a image in my view which is stored in the dataDirectory of the app. But when I set the image in the src tag, it returns a 404.

First I save the image returned from an api into the dataDirectory and normalize the URL:

this.file.writeFile(this.file.dataDirectory, filename, blob, { replace: true })
.then(function(fileEntry) {
	store.photoData = normalizeURL(fileEntry.nativeURL);
	resolve();
});

The normalized url of the image looks like this:

http://localhost:8080/var/mobile/Containers/Data/Application/1758E3DC-66D3-4481-8835-79C7841A540A/Library/NoCloud/1510162340797.jpg

Then I use it in my view:

<img *ngIf="store.photoData" [src]="store.photoData" />

Any ideas how to use a local resource image in a src tag? I don’t want to convert it back to base64.


#2

Yes! Found the answer myself!