Question

I'm trying to use the method setMetadata, using the File plugin, but it seems does not work.

No Success or Fail callback is executed. When I use console.log(entry.setMetadata), it prints the correct method. I use the File plugin to access, create and delete files and folders without problems. Only the setMetadata doesn't work.

Example:

    localFileSystem = LocalFileSystem.PERSISTENT;
    subFolder = "Backups";
    metadataKey = "com.apple.MobileBackup";
    metadataValue = 1;

    window.requestFileSystem(localFileSystem, 0, function(fileSystem) {
        fileSystem.root.getDirectory(subFolder, {create: true, exclusive: false}, function(parent) {

            var data = {};
            data[metadataKey] = metadataValue;
            console.log(data); // OK
            console.log(parent); // OK
            parent.setMetadata(function() {
                console.log("success setting metadata"); // Nothing
            }, function() {
                console.log("error setting metadata"); // Nothing
            }, data);
        }, function() {
            console.log("error getting dir"); // Nothing, directory is OK
        });
    }, function(error) {
        console.log(error.code); // No error here
    });
Was it helpful?

Solution

It was a bug on the File plugin. I checked with the developers on Github:

https://github.com/apache/cordova-plugin-file/pull/39

Just waiting for changes on the Phonegap site.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top