IOS Cordova installed local file as img src

I am using Plugo File Plugin to get a file to disk. I want to display this file in my application, so I have javascript:

image.src = imageFile.localURL;

      

However, I am getting an error when the url is not supported. I think this is because of the cdvfile: // prefix?

I also tried using the file entry:

imageFileEntry.nativeURL
imageFileEntry.toInternalURL()

      

But no luck. I either get an error when loading a local resource or that the url is not supported.

While searching for this problem, there are many questions, but no one has been able to solve my problem. Am I missing a step? Now I am doing:

  • Get FileEntry
  • Create Image Object
  • Set image source to file path from file entry

Do I need to set up any server on the device to host the file? Use a different plugin? What can I lose?

Relevant details of my setup:

  • My app is using WK โ€‹โ€‹Webview
  • I am loading a web page into an application that downloads and runs the code to display an image from a device.
  • The device runs iOS 10.2
+3


source to share


2 answers


Have you tried using the toURL () method?

Try connecting your console to the recording and make sure you get something like:

'File: /// var / mobile .........



I also had issues with spaces in the url on iOS.

Hello

0


source


WKWebview can only show img in cordova.file.tempDirectory

( file:///var/mobile/Applications/Container/Data/<GUID of app>/tmp/

), so you need to copy image files to tmp directory for display.



0


source







All Articles