I'm using the cordova-plugin-camera to get a picture from the album with navigator.camera.getPicture.
to destinationType: destinationType.FILE_URI.
This returns me a File_URI = file:///storage/emulated/0/Android/data/{app}/cache/IMG20200916194914.jpg?1600372401486 with the path that points to the cache folder where the image was saved.
And I need to place that image as a div's background to be used as a wallpaper, with something like this:
$("#imageCustom").css("background-image", "url(" + imageURI + ")");
Problem is that it throws an error that says:
Not allowed to load local: resource:file:///storage/emulated/0/Android/data/{app}/cache/IMG20200916194914.jpg?1600372401486
Is there a way to get a relative path to that folder/file to be accessed by the html?
Or may be moving the image to another folder and how I do that? (I copied it with resolveLocalFileSystemURL/requestFileSystem/copyTo/LocalFileSystem.PERSISTENT but only thing it does is copying it to the files folder where I have the same problem.
Thanks in advance.
Thanks to JM-AGMS
As posted in cordova load image file from device storage used the
cdvfile protocolincluded incordova-plugin-file.1.Added cdvfile: scheme to Content-Security-Policy meta tag of the index page, e.g.:
2.Added
<access origin="cdvfile://*" />toconfig.xml.3.And used to convert the path to the images: