使用cordova文件插件在创建文件时不会调用回调

时间:2014-12-09 14:02:54

标签: javascript cordova cordova-3 cordova-plugins

我在IOS 8.1上使用org.apache.cordova.file插件最新版本,但是当我尝试创建文件时没有任何反应:

getRootDirectory();

        function getRootDirectory() {
            console.log("getting root dir");
            window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, gotFS, fail);
        }

        function gotFS(fileSystem) {
            console.log('got fs', fileSystem);
            var fileName = "capb_logs.txt";
            var filePath = fileSystem.root.fullPath;

            if (filePath === '/') {filePath = '';}

            path = filePath + "/" + fileName;

            fileSystem.root.getFile(fileName, { create: true, exclusive: false }, gotFileEntry, fail);
        }

        function gotFileEntry(fileEntry) {
            console.log('gotFileEntry',fileEntry );
            fileEntry.createWriter(gotFileWriter, fail);
        }

        function gotFileWriter(writer) {
            console.log('gotFileWriter');
            writer.onwriteend = function(evt) {
                emailHandler.sendEmailWithAttachments({
                    subject: 'CA Executive Playbook - Debug Logs',
                    body: 'Log file attached',
                    attachments: [{
                        filePath: path
                    }],
                });
            };

            var logs = log.getAllLogs(false);
            writer.write(logs);
        }

        function fail(error) {
            console.log('Failed to get file', error);
            util.showMessage('Error', 'There was a problem in opening an email client');
            de.reject(error);
        }

我使用gotFs方法,但是当我调用fileSystem.root.getFile(fileName, { create: true, exclusive: false }, gotFileEntry, fail);没有任何反应时,调用成功或失败的回调都没有被调用。

这是我得到的文件系统对象:

enter image description here

0 个答案:

没有答案