Closed kd8ssq closed 5 years ago
Here's the error that the log shows
11-16 20:25:55.923 29328-29390/com.myApp.app1037 E/EmailComposer: Failed to get uri for file 11-16 20:25:55.924 29328-29390/com.myApp.app1037 W/System.err: java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/com.myApp.app1037/files/log.txt
I even attempted to hardcode the path and receive the same error
file:///data/user/0/com.myApp.app1037/files/log.txt
Looks like I have to use this format for android "app://databases/db.db3". When I tried that format for iOS it doesn't work, so I have to go back to using the dataDirectory for iOS.
@kd8ssq This is because of insufficient permissions.
If you use the latest master branch (0.9.0.beta), then you have to
READ_EXTERNAL_STORAGE
permission to your app's manifestRequest the permission:
var email = cordova.plugins.email;
email.requestPermission(email.permission.READ_EXTERNAL_STORAGE);
Please note that the permission is only needed for external files (file:///
). All other schemes don't need that permission.
Ok, thanks.
Is there a reason why I can successfully attach a file when the file is located in cordova.file.externalDataDirectory but not when it's located in cordova.file.dataDirectory? It's the exact same file, I just change where the file is saved/read from and when it's saved in the externalDataDirectory, the email plugin successfully pulls the text file into the email as an attachment.