cordova-plugin-file issues

14 views
Skip to first unread message

Doc Jump

unread,
Aug 24, 2017, 7:20:21 PM8/24/17
to phonegap
At this site, https://github.com/apache/cordova-plugin-file, create, read,write and remove file operations are demonstrated. I am attempting to use these functions, but there are problems. First of all, the created file overwrites itself each time it is executed, yet the isAppend variable value doesn't seem to matter. However, most disturbing for me is the write function definition and the corresponding call to that function. I suspect it has something very basic to do with javascript that I have yet to learn but here it is:

The write function is defined as so:
function writeFile(fileEntry, dataObj)
{
....
}

Yet, the call to the write function is specified like this:
writeFile(fileEntry, null, isAppend);

I have no idea how the differing and different number of function arguments can possibly work. Any assistance will be appreciated.

Kerri Shotts

unread,
Aug 24, 2017, 8:34:09 PM8/24/17
to phonegap
Those are two separate examples -- the first doesn't care about appending (only writing). The second one further down is the implementation you should use if you want to support appending to files ( see https://github.com/apache/cordova-plugin-file#append-a-file-using-alternative-methods- )

The "null" portion you're referring to is part of a check to see if the file exists or not, and is using the second writeFile definition. 

(Side note: In Javascript, you can pass a different number of arguments than the expected number of parameters, so it isn't a syntax error to over or under specify the number of arguments to a function. But in this case, the documentation seems a little confusing.)

Hope that helps?
Reply all
Reply to author
Forward
0 new messages