tizen.filesystem.resolve() 错误 - 对象的内容不包括有效值 [英] tizen.filesystem.resolve() error - The content of an object does not include valid values

查看:49
本文介绍了tizen.filesystem.resolve() 错误 - 对象的内容不包括有效值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am executing the following code in a Tizen web app I'm working on

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')

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

... and I am getting the following in the console

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

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

My question is , what's wrong with the code snippet above ? How am I supposed to invoke the Tizen filesystem API ?

提前致谢.

推荐答案

tizen.filesystem.resolve('.'

tizen.filesystem.resolve('.'

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

Above, you are trying to resolve . (root?) support for which is not required and probably you don't have an access to it.

VM569:10 错误:对象的内容不包含有效值.

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

这也证实了我的观察,来自文档:

This also confirms my observation, from the docs:

ErrorCallback 以以下错误类型启动:

The ErrorCallback is launched with these error types:

  • InvalidValuesError - 如果任何输入参数包含无效值.例如,只读虚拟根(wgt-package 和 ringtones)的模式为w".

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

Try to use one of the supported locations:

兼容实现必须支持的根位置列表是:

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

  • documents - 默认情况下,设备中存储文本文档(例如 pdf、doc...)的默认文件夹.例如,在某些平台上,它对应于我的文档"文件夹.
  • images - 默认情况下,设备中存储静态图像(如图片(格式包括 jpg、gif、png 等))的默认文件夹.例如,在某些平台上,它对应于我的图像"文件夹.
  • music - 默认情况下设备中存储声音剪辑(格式包括 mp3、aac 等)的默认文件夹.例如,在某些平台上,它对应于我的音乐"文件夹.
  • videos - 默认情况下,设备中存储视频剪辑(格式包括 avi、mp4 等)的默认文件夹.例如,在某些平台上,它对应于我的视频"文件夹.
  • downloads - 下载的文件(从浏览器、电子邮件客户端等来源)默认存储在设备中的默认文件夹.例如,在某些平台中,它对应于下载"文件夹.铃声:铃声(如 mp3 等)存储在设备中的默认文件夹.相机:存储设备拍摄的图片和视频的默认文件夹.
  • wgt-package - 小部件文件内容提取到的只读文件夹.
  • wgt-private - 小部件存储其信息的私有文件夹.此文件夹只能由同一小部件​​访问,其他小部件或应用程序不得访问存储的信息.
  • wgt-private-tmp - 临时的私有文件夹,小部件可以在其中存储小部件执行周期中可用的数据.当小部件关闭或 Web 运行时重新启动时,可以从此目录中删除此文件夹的内容.此文件夹必须只能由同一小部件​​访问,其他小部件或应用程序不得访问.
  • 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 参考.网站:

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"
);

这篇关于tizen.filesystem.resolve() 错误 - 对象的内容不包括有效值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆