Mitkins
Mitkins

Reputation: 4351

Cordova file plugin - overwrite files

As far as I can tell, there's no library call to replace a file (or folder). If I use FileEntry.copyTo or DirectoryEntry.copyTo and the destination exists, then I get INVALID_MODIFICATION_ERR (error 9).

If I delete the file first, then copyTo works. But what if something goes wrong? Is there an overwrite option I've missed somewhere? Or do I have to write my own code to ensure that the copy is successful before removing the original?

Upvotes: 4

Views: 3428

Answers (1)

user5524279
user5524279

Reputation:

You can add the exclusive: false option parameter to overwrite existing files.

Example https://github.com/apache/cordova-plugin-file/blob/master/README.md#create-a-persistent-file-

Upvotes: 3

Related Questions