javascript - tizen.filesystem.resolve() 错误 - 对象的内容不包含有效值

标签 javascript tizen tizen-wearable-sdk tizen-web-app tizen-web-simulator

我正在我正在开发的 Tizen Web 应用程序中执行以下代码

tizen.filesystem.resolve('.',
function (dir) {
    dir.listFiles(
        function (files) {
            for (var i = 0; i < files.length; ++i)
                console.log('File : ' + files[i].name + '\nURL : ' + files[i].toURI() + '\n========');
            } )
},
function (err) { console.log('Error : ' + err.message); window.__error = err },
'r')

...我在控制台中收到以下内容

null
VM569:10 Error : The content of an object does not include valid values.

我的问题是,上面的代码片段有什么问题?我应该如何调用 Tizen 文件系统 API ?

提前致谢。

最佳答案

tizen.filesystem.resolve('.'

在上面,您正在尝试解析 .(root?),对此的支持不是必需的,并且您可能无权访问它。

VM569:10 Error : The content of an object does not include valid values.

这也证实了我在文档中的观察:

The ErrorCallback is launched with these error types:

  • InvalidValuesError - If any of the input parameters contain an invalid value. For example, the mode is "w" for the read-only virtual roots (wgt-package and ringtones).

尝试使用受支持的位置之一:

The list of root locations that must be supported by a compliant implementation are:

  • documents - The default folder in which text documents (such as pdf, doc...) are stored by default in a device. For example, in some platforms it corresponds to the "My Documents" folder.
  • images - The default folder in which still images, like pictures (in formats including jpg, gif, png, etc.), are stored in the device by default. For example, in some platforms it corresponds to the "My Images" folder.
  • music - The default folder in which sound clips (in formats including mp3, aac, etc.) are stored in the device by default. For example, in some platforms it corresponds to the "My Music" folder.
  • videos - The default folder in which video clips (in formats including avi, mp4, etc.) are stored in the device by default. For example, in some platforms it corresponds to the "My Videos" folder.
  • downloads - The default folder in which downloaded files (from sources including browser, e-mail client, etc.) are stored by default in the device. For example, in some platforms it corresponds to the "Downloads" folder. ringtones: The default folder in which ringtones (such as mp3, etc) are stored in the device. camera : The default folder in which pictures and videos taken by a device are stored.
  • wgt-package - The read-only folder to which the content of a widget file is extracted.
  • wgt-private - The private folder in which a widget stores its information. This folder must be accessible only to the same widget and other widgets or applications must not be able to access the stored information.
  • wgt-private-tmp - Temporary, the private folder in which a widget can store data that is available during a widget execution cycle. Content of this folder can be removed from this directory when the widget is closed or the Web Runtime is restarted. This folder must be accessible only to the same widget and other widgets or applications must not be able to access it.

查看 API ref. site 中的示例代码:

var documentsDir;
function onsuccess(files) {
 for (var i = 0; i < files.length; i++) {
   console.log("File Name is " + files[i].name); // displays file name
 }

 var testFile = documentsDir.createFile("test.txt");

 if (testFile != null) {
   testFile.openStream(
     "w",
     function(fs) {
       fs.write("HelloWorld");
       fs.close();
     }, function(e) {
       console.log("Error " + e.message);
     }, "UTF-8"
   );
 }
}

function onerror(error) {
 console.log("The error " + error.message + " occurred when listing the files in the selected folder");
}

tizen.filesystem.resolve(
 'documents',
 function(dir) {
   documentsDir = dir;
   dir.listFiles(onsuccess, onerror);
 }, function(e) {
   console.log("Error" + e.message);
 }, "rw"
);

关于javascript - tizen.filesystem.resolve() 错误 - 对象的内容不包含有效值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35712612/

相关文章:

javascript - Webpack提取文本插件未知单词导出错误

javascript - 在多个 URL 上具有相同的 Disqus 线程

tizen - 将 Tizen 应用程序部署到 Gear S2 : Non trusted certificate is used

javascript - 如何使用 Tizen Web studio 在我的应用程序中使用下载的 svg 文件?

javascript - 数学游戏 JQuery/JavaScript

javascript - 如何检查 Svelte 应用程序的浏览器兼容性?

javascript - Tizen gear Web 应用程序,启动带有文本数据的 Web 应用程序

html - Tizen - 如何更改按钮字体大小 - 已修复

javascript - 在 tizen web 应用程序中保存数据

Tizen 工作室 : Unable to install application due to signature error in certificate profile (Error: -12)