I’m working on Android app with IONIC, and I use Camera API and File API.

The goal is that user, select one image from their library, and the app copy that image to their working directory.

When they select the image using camera API:

I can’t access image to copy it, i get this message in catch of copyFile:
“FileError {code: 2, message: “SECURITY_ERR”}”

Any help?

It’s says that is security error

does the app granted file system access ?

Yes, but I have:
uses-permission android:name=“android.permission.CAMERA”/>
uses-permission android:name=“android.permission.INTERNET”/>
uses-permission android:name=“android.permission.WRITE_EXTERNAL_STORAGE”/>
uses-permission android:name=“android.permission.REQUEST_INSTALL_PACKAGES”/>
in the config.xml… WRITE_EXTERNAL_STORAGE is grant file system access, right?

You need to have get the permisson to read the files too

merge this permissions to your app

<uses-permission android:name="android.permission.INTERNET" />
    <!-- Camera, Photos, input file -->
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <!-- Geolocation API -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-feature android:name="android.hardware.location.gps" />
    <!-- Network API -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!-- Navigator.getUserMedia -->
    <!-- Video -->
    <uses-permission android:name="android.permission.CAMERA" />
1 Like

Thanks, but if I put this permissions on config.xml they dissapear every time I compile.

I put the permissions on plugin.xml iof cordova-plugin-file… but not work, even with the READ_EXTERNAL_STORAGE…

Don’t ask me why… but now it works. Thanks for help Arazinejad.

1 Like