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
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none
Accepted Solution

BB10 - blackberry.io - access "sharedFolder" only

Hi,

 

I'm playing around with the new blackberry.io API for BB10 and the example provided in the linked API documentation. It seems to work well, but it also provides access to all files in the filesystem. Right now I wanted to only recursivly access the "sharedFolders" like provided when connecting the BB10 Dev Alpha to a PC via USB, since there isn't an app to access created images/videos by camera app.

 

Somebody know how to access only the "sharedFolder"? Would be nice to have some more informations in the documentation available. I searched the Forum, but couldn't find something here.

 

Regards.


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Highlighted
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: BB10 - blackberry.io - access "sharedFolder" only

Will answer my quesions by myself, also to provide those informations for all others:

 

// un-sandbox file system to access shared folder
blackberry.io.sandbox = false;

window.requestFileSystem  = window.requestFileSystem || window.webkitRequestFileSystem;

window.requestFileSystem(window.TEMPORARY, 5 * 1024 * 1024, function (fs) {
	// in order to access the shared folder,
	// config.xml must declare the "access_shared" permission
	// reference file by absolute path since file system is un-sandboxed
	fs.root.getDirectory('/accounts/1000/shared', {}, function(dirEntry) {
		var dirReader = dirEntry.createReader();
		var entries = [];
		// Call the reader.readEntries() until no more results are returned.
		var readEntries = function() {
			dirReader.readEntries(function(results) {
				if(!results.length) {
					// do some functionality to list entries like:
					listResults(entries.sort());
				} else {
					entries = entries.concat(toArray(results));
					readEntries();
				}
			}, errorHandler);
		};
		readEntries(); // Start reading dirs.
	});
}, errorHandler);

Hint: not all of the functions used above are added to this piece of source code.

 

Hope this will be helpful to you!!!

 

Regards.


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.