metro应用实现断点续传的问题 RRS feed

  • Question

  • 大家好!

    • Edited by caiyunol Wednesday, August 22, 2012 2:41 AM
    Wednesday, August 22, 2012 2:35 AM


  • Hello everyone!
    Advisory question.
    Issues prospects need to implement a resumable download music above the server, the server supports resumable.
    Achieve download time using DownloadOperation to achieve, there are 2 questions, to the detriment of my implementation resumable
    First: Resume of the DownloadOperation () method, is re-download not restore from suspend place to start the download.
    Second: when he downloaded data is not saved to a local file. Feeling is that after downloading a one-time saving.
    Understand why students pointing resumable implementations.
    There is also a problem. Started when I have used HttpClient to download.
    Discover HttpClient Timeout needs to be set to 2 minutes to download. Otherwise the old failed. 2 minute wait time is too long. Makes people great trouble. Is associated with speed. Pad is used for basic wireless now. Speeds should not fast.

    According to the bing translator :) , here are the answers:

    1) Resume method does resume on cases where resume is possible. Meaning if the server accepts range-requests, the download would resume, otherwise restart.

    2) When you are creating the storage file store your data, you have to use GenerateUnique name enum value to avoid overriding the existing file.

    StorageFile destinationFile = await KnownFolders.PicturesLibrary.CreateFileAsync(
                        destination, CreationCollisionOption.GenerateUniqueName);
    BackgroundDownloader downloader = new BackgroundDownloader();
    DownloadOperation download = downloader.CreateDownload(source, destinationFile)

    3) If the HttpClient is giving you a hard time with the download, you can always embellish it with a download progress. This would sustain the fluid UI and avoid non responsive application. Here is an example that is to be used with servers which allow chunked encoding: Download / Send Request Async with Progress

    Hope it helps, and you might want to try to post it to a local group rather than the english one. You might get more responses.

    Can Bilgin
    Blog CompuSight

    Wednesday, August 22, 2012 10:33 AM