我正在尝试(非常简单地)使用webworks获取相机目录的文件列表。我正在尝试的代码如下:
function displayPhotos(id) {
try {
var Dir, path, items;
if ((window.blackberry === undefined) || (blackberry.io === undefined) || (blackberry.io.file === undefined)) {
appendContent("photoDetails", "<p><i><b>blackberry.io.file</b> object not found (likely cause is WebWorks APIs are not supported by this user agent).</i></p>");
debug.log("displayPhotos", "blackberry.io.file object is undefined.", debug.error);
return false;
}
Dir = blackberry.io.dir;
path = "";
path = "file:///Device/home/user/camera"";
items = Dir.listFiles(path);
console.log(items);
//setContent(id, formatAsHTML(path, items));
}
catch(e) {
console.log("displayPhotos", e, debug.exception);
}
}所有我得到的是错误1004 -我假设这是基于权限的,但我不相信我不能在相机上读取失败-有人知道什么吗?
干杯!
发布于 2012-05-30 18:55:24
好吧,我想出来了,希望这能帮助任何人得到可怕的黑莓webworks错误1004。
您需要在存储路径中更改设备。真的就是这样。此示例有效:
function displayPhotos(myFolder) {
try {
var Dir, path, items;
Dir = blackberry.io.dir;
path = "";
if (myFolder != undefined){
path = myFolder;
} else {
path = "file:///store/home/user/pictures";
//file:///store/home/user/camera
}
items = Dir.listFiles(path);
return items;
}
catch(e) {
console.log("displayPhotos", e, debug.exception);
}
}
function displayFiles(myFolder) {
try {
console.log("displayFiles", "in " + myFolder);
return displayPhotos(myFolder);
}
catch(e) {
console.log("displayFiles", e, debug.exception);
}
}你可以这样称呼它:
displayFiles();或者指定文件夹,如下所示:
displayFiles("file:///store/home/user/camera");返回文件名数组。
希望这对某些人有帮助!
https://stackoverflow.com/questions/10801801
复制相似问题