Specifying the full file name

13 views
Skip to first unread message

Doc Jump

unread,
Jul 28, 2016, 8:21:44 PM7/28/16
to phonegap
Hello. Can anyone refer me to some phonegap documentation that explains how to express a full path to a file.

For example, I use this:
fs.root.getFile('docj.txt', {create: true}, function(fileEntry) {
to create a file named docj.txt. This works fine since I can write, read and delete this file by just specifying the name 'docj.txt'.
Also, I found the full path with this command:
alert(fs.root.fullPath) which was just a forward slash "/".
However, when I specify the same file as an email attachment like this:

cordova.plugins.email.open({
        app: 'gmail',
        to: 'geo...@cyberwurks.com',
        subject: 'Database',
        body: 'Database Attached',
//['file:///data/docj.txt']});
        attachments:'docj.txt'});  or attachments:'/docj.txt'}); don't work. The email system says "cannot attach emplty file".

Any help will be appreciated. Thanks.

I assume that the attachment statement needs the full path and file name. However, I have no idea how to express the full path. Hence I am looking for some docs that explain it.

Kerri Shotts

unread,
Jul 30, 2016, 3:37:22 PM7/30/16
to phonegap
I don't know if the email plugin supports it or not, but you might try the cdvfile:// scheme (e,g, "cdvfile://localhost/persistent/docj.txt"). But it would be incumbent upon the plugin to translate that to the appropriate URI.

The file entry should also have a toURL() method that can provide a full path (https://github.com/apache/cordova-plugin-file#upgrading-notes), but be wary -- there are issues in Android N that cause any exposure of a file:/// path outside the app to crash with an exception. Although N is not yet supported, it's something to be wary of.

So right now you're dealing more with the plugin's support of files rather than the File API's handling. Can you link to the specific plugin you're using for emails? (I could guess, but if I'm wrong, that's of no benefit to you.)

On Thursday, July 28, 2016 at 7:21:44 PM UTC-5, Doc Jump wrote:
...
Reply all
Reply to author
Forward
0 new messages