80851

Ionic 3: File_URI Not allowed to load local resource IOS

Question:

Im using the camera to take an image and preview it. It needs to be sent to a server so Im using the destination type of 'FILE_URI'. It works when I run it on android, but Im getting this error running it on ios 10.3.1

Not allowed to load local resource : file:///var/mobile/Containers/Data/Application/2CE518F3-4F4E-42A9-94E1-DC06D01250C7/tmp/cdv_photo_001.jpg

I am not running it with the -lc tag. The encoding type is JPEG

Answer1:

I was facing same problem and I realized that in iOS camera plugin returns source with protocol for new captures but when using it in your HTML to set the source of an element like img or video you need to remove protocol... So I did :

if (isIos()) { itemSrc = itemSrc.replace(/^file:\/\//, ''); }

If you want to move capture to somewhere else restore protocol or make a copy beforehand or whatever

Hope it helps

Answer2:

I was running the app in livereload mode and facing the same problem and I tried <a href="https://stackoverflow.com/questions/37090706/ionic-cordova-fileupload-error-not-allowed-to-load-local-resource" rel="nofollow">this answer</a>, changing from livereload to normal mode solved the problem.

It should help you as helped me, at least for now.

Answer3:

use this path = normalizeURL(path); and also read more about <a href="https://ionicframework.com/docs/wkwebview/" rel="nofollow">WKWebView</a>

Recommend

  • using find but only in subdirectories matching certain pattern
  • Deployed Azure Function (v2) not running
  • Lambda inside loop
  • MongoDB document as a JsonNode (Jackson library)
  • Read certain line in text file and display the next
  • How to refresh by pulling down the items?
  • Create multidimensional array based on value of key
  • Adding in new XML root node
  • Youtube Android/IOS SDKs don't seem to count views when playing
  • jQuery/mobile Safari bug?
  • Comparing a large set of images by content
  • Why doesn't the tray icon context menu work for my RemoteApp?
  • Google Geocoding API limit exceeded on cell network, but not on wifi
  • Firestore: Version history of documents
  • Multiple canvases (pages) in Fabric.js
  • How to define a custom accuracy in Keras to ignore samples with a particular gold label?
  • flex tree gets chopped even after using scroll bar
  • Create an average of multiple excel chart without the data source
  • Calculate time from document
  • I am consuming a WCF service that requires headers from a .NET 2 website. How can I programmatically
  • how to run ejabberd with Erlang on Heroku?
  • How to use Streams api peek() function and make it work?
  • jQuery scrollTop if URL has hash
  • `$http:badreq Bad Request Configuration` - from angular post method, what is wrong here?
  • php “page caching” solution suggestions for CMS Applications
  • Computing the discrete fourier transform of audio data with FFTW
  • Grails - How to implement a foreign key relationship not using an id column?
  • VLOOKUP in IMPORTRANGE
  • Jersey serializes character value to ASCII equivalent numeric string
  • CAS 4 - Not able to retrieve the LDAP groups after successful authentication
  • What does the “id” field in an Android “Google Play Music” broadcast intent correspond to?