Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Contributor
bazzlad
Posts: 7
Registered: ‎03-01-2012
My Device: Bold 8800
My Carrier: N/A

Webworks IO + Camera Directory - possible?

I'm trying to use the File api to get a list of the files in the camera directory - I'm getting a 1004 error (what ever that means [I'm praying it's not permissions based]).

 

Simple question - Can I get my list?

 

Cheers!

Please use plain text.
New Contributor
bazzlad
Posts: 7
Registered: ‎03-01-2012
My Device: Bold 8800
My Carrier: N/A

Re: Webworks IO + Camera Directory - possible?

No mods around? I'd think this would be a yes or no answer! (and my development is stalled until I know for sure!)

Please use plain text.
New Contributor
bazzlad
Posts: 7
Registered: ‎03-01-2012
My Device: Bold 8800
My Carrier: N/A

Re: Webworks IO + Camera Directory - possible?

Thanks for all the help
/S

After a day or so of fiddling I finally figured it out, I'm posting this on the off chance it helps another frustrated programmer.

 

 

Hope this helps anyine getting the dreaded blackberry webworks error 1004.

You need to change device in the path to store. That's it really. This example works:

 

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


You can call it like so:

displayFiles();

Or specify a folder like so:

displayFiles("file:///store/home/user/camera");

Returns an array of filenames.

Hope this helps someone!


 

Please use plain text.