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 Developer
Posts: 12
Registered: ‎04-27-2009
My Device: Z30, PlayBook
My Carrier: Rogers

PlayBook TabletOS - Download Large Files - WebWorks

Hi all,

 

I am developing a WebWorks app on the PlayBook that will download updated files (ranging from Kb's to at least a few Mb's) when the program is started.

 

I was trying to use the following APIs but it does not seem to work properly (for me at least), the files appear to get downloaded, but it never reaches the success function. The documentation says that if you set the progressInterval to 0, it will call the success function once finished (rather than on a frequency)... but it doesn't appear to.

https://github.com/blackberry/WebWorks-Community-APIs/tree/master/Tablet/UploadDownload

 

try {
					var ft = blackberry.io.fileTransfer;
					var options = { 'progressInterval' : 0, 'username' : '', 'password' : '', 'connectionTimeout' : 30000, 'BESMaxSingleChunk' : 3279 };
            		var downloadRemote = remotePath + "/data.php";
            		var downloadLocal = localPath + "/data.xml";
					var sizeInBytes = ft.getRemoteFileSize(downloadRemote);
            		if (sizeInBytes > 27498274) { alert("File is too large to download."); return; }
					ft.download(downloadRemote, downloadLocal, loadXMLSuccess, loadXMLFailure, options);
				} catch (e) {
					alert("Exception: " + e);
				}

	function loadXMLFailure(error) {
		alert("Error Code: " + error.code + "\n Error Description: " + error.description);
	}

	function loadXMLSuccess(status) {
		if (console && console.log) {
			 console.log("Percent complete: " + status.percent +
				  "\nTotal file size: " + status.totalFileSize +
				  "\nBytes downloaded: " + status.numBytes +
				  "\nLocal path: " + status.localPath +
				  "\nRemote path: " + status.remotePath +
				  "\nRedirect path: " + status.redirectPath + 
				  "\nStart time: " + (new Date(status.startTime)).toDateString() +
				  "\nMIME type: " + status.mimeType
			 );
		}
	}	

 

Has anyone been able to implement this API or anything similar to handle the downloading of files for TabletOS?

 

Thanks,

 

James

Developer
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C
My Carrier: 3, Orange, Vodafone

Re: PlayBook TabletOS - Download Large Files - WebWorks

This API is badly broken - no, you can't use it

 

On PB you need AJAX + the app.file.* stuff

 

I'm finding this damned annoying as well as in a few months PB becomes BB10




Click the like button if you find my posts useful!
New Developer
Posts: 12
Registered: ‎04-27-2009
My Device: Z30, PlayBook
My Carrier: Rogers

Re: PlayBook TabletOS - Download Large Files - WebWorks

Yeah, I had a feeling that it was broken as I tried for a long while to get it to work, examples seemed quite confusing and contradictory to each other... on the other hand, the BB10 API had the functions I had wanted but could not use... 

 

Do you have any links to examples for a reliable AJAX method of downloading? Or recommend a specific framework (ex. jQuery)?