katzer / cordova-plugin-email-composer

Edit and send email messages
Apache License 2.0
343 stars 333 forks source link

Attach files from the internal app file system using file:/// #354

Closed jfoclpf closed 3 years ago

jfoclpf commented 3 years ago

For internal app file system you suggest using this:

cordova.plugins.email.open({
    attachments: [
        'app://databases/db.db3', //=> /data/data/<app.package>/databases/db.db3 (Android)
        'app://databases/db.db3', //=> /Applications/<AppName.app>/databases/db.db3 (iOS, OSX)
        'app://databases/db.db3', //=> ms-appdata:///databases/db.db3 (Windows)
    ]
});

But I realized the file:/// pattern doesn't work for internal app file system. Why not accepting also paths like file:///data/data/<app.package>/<dir>/filename or file:///data/user/<app.package>/<dir>/filename for internal app file system? This is important because these paths are the ones which come from the cordova-plugin-file

jfoclpf commented 3 years ago

My point is that this path does not work as attachment file:///data/user/0/com.form.parking.violation/cache/img1.jpg but this works app://cache/img1.jpg

jfoclpf commented 3 years ago

@katzer if your have a time for this, it would be nice ;)

jfoclpf commented 3 years ago

In android I solved the issue with

path.replace(cordova.file.applicationStorageDirectory, 'app://')