Cordova.Camera.GetFile

Hi all,

I have been using the Camera plugin to add photos to an app I am making. There are two options, take a new photo, or select a photo from the library.

If an image is selected from the library it is copied to the local app cache. This was necessary because I was finding that trying to load the image from the provided URI directly was failing unless the camera has been opened in some way. (e.g, if you close the app, open it again and then try to view an image using the previously attained URI, it would fail)

Now, my solution of copying the image to cache was working just fine UNTIL my phone upgraded to Android 4.4 with the new storage framework. This issue is detailed in the Android Quirks section of this document http://docs.phonegap.com/en/edge/cordova_camera_camera.md.html

The possible solutions links to suggest editing “core” android code, something I would like to avoid when using ionic/cordova. So I am wondering, has anyone managed to integrate a fix into a cordova/ionic project?

Thanks as always!
-Chris

So…

I think I’ve kind of managed something here. By looking at the camera plugin code I discovered that if “allowEdit” was true, the selector was different, so I just set allowEdit to false, which reverted the file selector and fixed my issue.

Not ideal but at least the app works again! :smile:

Hey,

So what I decided to do in the end was to us the camera from the ngCordova library and than i have it return the Base64 string of the image and store that in localstorage to use later.

What this gave me was that the image would always be there, even if they deleted it off there phone, it was a bit faster to access and I didnt rely on the OS.

Just my 2c

Hey Dale, I never even considered storing the image data in local storage. I store everything else there, so it sounds like an elegant solution. Is there an upper limit to local storage space because I imagine if you’ve got around 50 images it would fill up quickly?

Ta
-Chris

Hey,

Yeah thats something i have yet to figure out, my solution to it though would be to then just store each image individually rather than all in the same value. I also limit the size of my images to 250px and make the jpegs so for the most part they are all quite small.

1 Like