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

Posts: 15
Registered: ‎02-07-2012
My Device: BlackBerry PlayBook
My Carrier: AT&T

Download files from external server and store to PlayBook

I have an app with many thousands of support files, each an HTML file that is loaded in the various screens of the application.  There are so many support files that the RDK.SF file (a file created during the app signing process and that lists all files that are part of an application) becomes too large and causes the signing process to fail (I've filed a bug on this, and I'm told that this is an issue RIM is aware of).


So, instead of packaging all of my support files inside the app, I'd like the app to download the files onto the PlayBook into the root directory of my app the first time the app runs.


In WebWorks/HTML5, how do I store a downloaded file to the PlayBook? I already know how to get the contents of a remote file, but how can I save that content into a new HTML (or whatever) file and store it in the root directory of the app?


BlackBerry Development Advisor
Posts: 769
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: Download files from external server and store to PlayBook

You could use the UploadDownload extension to physically download the file to the device (you specify the save path).  


You can check-out the extension over on our GitHub repo https://github.com/blackberry/WebWorks-Community-APIs/tree/master/Tablet/UploadDownload

New Developer
Posts: 3
Registered: ‎10-02-2012
My Device: Playbook 16GB
My Carrier: verizon

Re: Download files from external server and store to PlayBook

You should actually be able to use the FileTransfer API. While it doesnt show that the PB is supported. It actually should be. I think the documentation is a little off in that respect. As just below the compadiblity chart, it metnions playbook not needing permissions. Anyway: check out https://developer.blackberry.com/html5/apis/blackberry.io.filetransfer.html  i added some relevent code below (Also Note you'll probably need to use the HTML File/FileSystem API as well)


<script type="text/javascript">

function downloadSuccess(result) {
  alert("Download was successful");
  console.log("isFile: " + result.isFile);
  console.log("isDirectory: " + result.isDirectory);
  console.log("name: " + result.name);
  console.log("fullPath: " + result.fullPath);

function downloadError(result) {
  alert("Download failed");
  console.log("Error code: " + result.code);
  console.log("Source: " + result.source);
  console.log("Target: " + result.target);
  console.log("HTTP status: " + result.http_status);

function fileDownload() {
  try {
    blackberry.io.filetransfer.download("http://www.blackberry.com/download", "/accounts/1000/shared/camera/image_123.jpg", downloadSuccess, downloadError);
  } catch(e) {
    alert("Exception in fileDownload: " + e);