FileTransfer open failed: EACCES (Permission denied)


Since few months I’m trying to resolve an issue with the FileTransfer plugin. My app let the user upload pictures, videos and voice. Pictures work well since I convert them to a base64 code.

But videos and voice are not working.

Here is my Ionic info ouput :

cli packages:

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1) 

local packages:

    @ionic/app-scripts : 3.2.4
    Cordova Platforms  : android 8.1.0
    Ionic Framework    : ionic-angular 3.9.9


    Android SDK Tools : 26.1.1
    Node              : v7.8.0
    npm               : 4.2.0 
    OS                : Linux 5.11

Here is my code to handle video capture and upload :

/* Function to launch phone camera, with duration limited to 30 seconds */

getFromCamera() {
    let options: CaptureVideoOptions = { duration: 30 };

    this.mediaCapture.captureVideo(options).then((data: MediaFile[]) => {
        return this.sendVideo(data, 'camera');
    }, (err) => {
/* Function to handle upload */

sendVideo(data: any, type: string) {
    if (type === 'camera') {
      data = data[0].fullPath;

    let options: FileUploadOptions = {
        chunkedMode: false,
        mimeType: 'multipart/form-data',
        fileKey: 'file',
        fileName: 'file',
        headers: { 'x-auth-token': 'apitoken...' }

    this.videoFileUpload = this.fileTransfer.create();
    this.videoFileUpload.upload(data, API_URL + '/v.1/api/notes/videos', options).then(res => {
        return console.log(res);
    }, (err) => {
        return console.error(err);

code simplified

And this return me :

FileTransferError {code: 1, source: "file:///storage/emulated/0/DCIM/Camera/VID_20211018_132957.mp4", target: "", http_status: 500, body: "{\"success\":false,\"error\":{\"code\":400,\"messages\":[\"This video is too long or corrupted\"]}}", …}
body: "{\"success\":false,\"error\":{\"code\":400,\"messages\":[\"This video is too long or corrupted\"]}}"
code: 1
exception: "/storage/emulated/0/DCIM/Camera/VID_20211018_132957.mp4: open failed: EACCES (Permission denied)"
http_status: 500
source: "file:///storage/emulated/0/DCIM/Camera/VID_20211018_132957.mp4"
target: ""

Same issue with video coming from phone gallery.

This work well on Android <= 9 but not on Android 10+ since the new storage methods. I tried many methods, like setting android:requestLegacyExternalStorage in config.xml, but this throw me an error on ionic cordova build android : AAPT: error: attribute android:requestLegacyExternalStorage not found. Others methods are not working too

So I don’t know how to make this work when targeting SDK 30 (to fit GooglePlay requirements). And if this is possible for Android 10+ :confused: , is there is something to do ? Use a new plugin ? Force permissions ?

Thank you for your help.

Up. I think I’m not the only one is this situation. This is a blocking situation with my clients :confused:

Problem is always active. Now this is not working, and also the app is refused from the PlayStore because some plugins use a “forbidden” permission on Android. About external storage.

Same problem and still not solved… :thinking: :unamused:

I have same problem, the play store say: I need use API MediaStore. I don’t know how this is…