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
Posts: 33
Registered: ‎10-29-2013
My Device: BB10
My Carrier: TMO
Accepted Solution

How to show a progress bar on file download?

Hi,

Is it possible to display a progress bar on blackberry.io.filetransfer.download function? I don't know how to get a file size before download start from the server? I saw also that bbui.js has a progress indicator that would work ok if i knew how to calculate  total file size before download and changing file size in bytes on the device.

 

thanks

Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: How to show a progress bar on file download?

You would need a server-side script that returns the size of the file to you that you could query prior to initiating the download. I'm not seeing anything in the APIs that would provide this value directly during a transfer.

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Highlighted
Developer
Posts: 33
Registered: ‎10-29-2013
My Device: BB10
My Carrier: TMO

Re: How to show a progress bar on file download?

Eventually I found a solution for this proglem. You need to use html5 XMLHttpRequest to which you can bind onprogress event and calculate procent of the loaded data. https://github.com/blackberry/BB10-WebWorks-Samples/tree/master/fileTransfer has an example for this but unfortunately a pure html5 file transfer is not working there because blobbuilder was deprecated. Thr drawback of this approach is that all the loaded data is kept in the memory before writing to a file system and it is not suitable for large files. The device gets out of memory and the OS starts closing all the opened windows/apps until in the end it closes even the running app Smiley Happy