downloading multiple files using BackgroundTransfer RRS feed

  • Question

  • Hi.

    I was wondering if it's possible to pass a list of files that i would like to download to the backgroundTransfer API so it can download them all.

    I'm suppose to download around 280 files, most less than 400KB and my fear of using XHR is that when the app suspends, then the download would pause (or stop, ...., not sure). But my fear with using background transfer is that although it downloads the file in the background, it doesn't run app code when suspended, so if 1 file completes its download, and i have a for loop that starts the next download when one completes, my guesses are that it won't iterate to the next download since its suspended.

    So i'm wondering if i can pass an array of files that i want downloaded by the BT API that will automatically download one file after the other. (and then of course give me the progress of each download, whether its completed, or downloading, or is queued).

    Thank you. 

    • Edited by ICode. _ Monday, October 1, 2012 5:13 PM
    Monday, October 1, 2012 5:11 PM

All replies

  • You would have to reconnect to downloads when your app is activated again and attach your progress / complete handler to the download. If the file has been downloaded it will instantly call your complete handler, if its still downloading the progress handler and in case of an error your error handler. See the background file transfer sample.

    About the download of multiple files, it should handle that.

    • Edited by phil_ke Monday, October 1, 2012 8:19 PM
    Monday, October 1, 2012 8:19 PM
  • Thanks for the reply.

    Yea, i read the sample earlier today. So there's absolutely no way of downloading multiple files in the background?

    The reason why i want to do so is because, well, from a 'What The User Expects To Happen' perspective, its extremely impractical! It's impractical that a user must have my app opened (and activated/focused) in order to download 280 files. As soon as the user sees that the download is taking time, most probably he/she will go and do something else (impatient people these days ^.^ ).

    Then (s)he comes back to see that its only at the 4th file (one file after where it was left off) and then realizes that 'oh, i must have the app focused to download all the files. Well this is inconvenient and a waste of time!'.

    I want the app to be seamless and do what's expected.

    With that being said. If the BT cant take an array of files to download,....., Is there a way that i can run code in the background? a particular API or something?

    again, Thanks.

    • Edited by ICode. _ Monday, October 1, 2012 9:08 PM
    Monday, October 1, 2012 9:07 PM
  • What you could do once you started to download the files is to register a background task that gets executed like 15 minutes in the future to perform additional tasks on behalf of your app. The downloads continue to work when your app is not active though. Thats the meaning of "Background" in "BackgroundFileTransfer" ;)
    Tuesday, October 2, 2012 8:04 AM
  • So i got happy to find that there's something called the background task. But i can only use it using a SystemTrigger? i.e. i have to wait some time? (15 mins or so?) or for a specific trigger to happen? See: SystemTriggerTypes

    I need the app to download multiple files when the user clicks on "download". So there isn't really a systemtrigger that i can use.

    I'm starting to guess that there's is no clean way of doing this?

    Tuesday, October 2, 2012 9:16 PM
  • If you want to download multiple file you can do that by putting all the files in BT api, you must call "DownloadOperation.StartAsync()" and attach the progress.

    However if you want to download next file after previous one is completed, i believe you cannot do that when app is suspended.

    Tuesday, July 30, 2013 7:21 AM