是否可以使用Ripple模拟器testingPhoneGap File API

我正在使用PhoneGap(现在是Apache Cordova,版本为2.0)的应用程序,并使用PhoneGap File API写入文件。

我使用的File API可以参考: http : //docs.phonegap.com/en/2.0.0/cordova_file_file.md.html#File

我使用从这里的纹波模拟器(0.9.9beta): https : //developer.blackberry.com/html5/downloadtesting我的应用程序在铬。

但是我发现Ripple无法正确处理PhoneGap File API。

例如:

我想在PERSISTENT目录下创build一个文件(root / foo.json)

function onSuccess(fileSystem) { fileSystem.root.getDirectory("dir", {create: true}, function(dirEntry){ dirEntry.getFile("foo.json", {create: true}, function(fileEntry){ fileEntry.createWriter(function(writer){ writer.write(JSON.stringify(fooData)); }, onfail); }, onfail); }, onfail); } function onfail(error) { console.log(error.code); } // request the persistent file system window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onSuccess, onfail); 

它在iOS模拟器上工作正常,它在正确的位置创build了正确的文件,但是在运行在chrome中的Ripple Emulator中,我刚刚得到了一个onfailcallback,并得到了错误代码10(FileError.QUOTA_EXCEEDED_ERR)。

我还发现有人在这里有类似的问题: 它是否能够testing模拟器外的phonegap应用程序?

但仍然没有答案。

Ripple模拟器目前是否无法正确使用PhoneGap API? 还是我错过了一些设置?

发现问题。 我需要在使用PERSISTENT文件系统对象之前授予配额。 https://developers.google.com/chrome/whitepapers/storage#persistent

 // Request Quota (only for File System API) window.webkitStorageInfo.requestQuota(PERSISTENT, 1024*1024, function(grantedBytes) { window.webkitRequestFileSystem(PERSISTENT, grantedBytes, onInitFs, errorHandler); }, function(e) { console.log('Error', e); }); 

看来Ripple-UI并没有为我做这件事(我在lib / ripple / fs.js上查看了源代码)。 这就是为什么我总是得到一个FileError.QUOTA_EXCEEDED_ERR。