1



I'm developing an iOS & Android mobile app with Cordova, and i'm facing a problem with saving and displaying a picture taken from camera or camera roll, and saved locally.

I've already seen other conversations on the subject :
Save image in local storage phonegap
Capturing and storing a picture taken with the Camera into a local database / PhoneGap / Cordova / iOS

I'm using the scripts described in these conversations which are good, but finally can't achieve to display the saved pictures.

I know pictures have been successfully saved in a persistent folder on my iPhone, i can see them, using iExplorer software, in my app subfolders, for example : Documents/MyApp/cdv_photo_002.jpg

And i save in my localStorage the fullPath of the local picture and obtain something like : file:///var/mobile/Containers/Data/Application/4E70258E-8060-48A6/Documents/MyApp/cdv_photo_002.jpg

When i try to put this path in an img src, nothing is displayed as if the picture did not exist or not having this path...
How can i display my local pictures ?

Community
  • 1
  • 1
  • Does your app got READING and writing permissions? – jcarrera Jan 19 '16 at 10:45
  • Do you see an error in console? – Raymond Camden Jan 19 '16 at 11:32
  • Yes, i have r/w permissions and i have no error in console – Matthieu Marcé Jan 19 '16 at 15:27
  • Did u get any solution? – Mohanvel V Feb 17 '16 at 05:07
  • yes, the problem was about fetching the local system path, so i had to put the path in a local storage item using `window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSys) {localStorage.setItem('_localsys', fileSys.root.toURL());});` – Matthieu Marcé Feb 17 '16 at 11:18
  • I get the fileSys roo url as "file:///Users/name/Library/Developer/CoreSimulator/Devices/A8243D1F-24C4-437D-BAC5-76EBF99B68FB/data/Containers/Data/Application/C9B9F008-F56F-4C6D-B692-4DF73E5EE8B8/Documents/". How to get the image url – Mohanvel V Mar 02 '16 at 08:04
  • Colud u pls suggest solution for me? Am getting entry.nativeURL as "file:///Users/mohanvel.v/Library/Developer/CoreSimulator/Devices/A8243D1F-24C4-437D-BAC5-76EBF99B68FB/data/Containers/Data/Application/ED53ACD1-FF4F-416E-8499-D4FDB9894A31/Documents/xxx/cdv_photo_001.jpg", how to display this image – Mohanvel V Mar 02 '16 at 11:38

1 Answers1

1

As Matthieu Marcé pointed out, the answer of this question should be :

the problem was about fetching the local system path, so i had to put the path in a local storage item using

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
function(fileSys) {
      localStorage.setItem('_localsys',fileSys.root.toURL());
   }
);
Alexandre Rozier
  • 960
  • 1
  • 8
  • 21