locked
Download zip file using background transfer

    Question

  • Hi,

       I have downloaded zip file using background downloader and my file size is greater than 10 mb

     function DownloadFile(uriString, fileName, tablename) {
        dot = fileName.split('.');  
        var basename = dot[0];
        try {
            // Asynchronously create the file in the Application Local folder.
            Windows.Storage.ApplicationData.current.localFolder.createFileAsync(fileName, Windows.Storage.CreationCollisionOption.replaceExisting).done(function (newFile) {
                var uri = Windows.Foundation.Uri(uriString);
                var downloader = new Windows.Networking.BackgroundTransfer.BackgroundDownloader();
                // Create a new download operation.
                download = downloader.createDownload(uri, newFile);
                // Start the download and persist the promise to be able to cancel the download.
                promise = download.startAsync().then(downloadCompleted, downloadFailed, downloadProgress);
               
            }, function (err) {console.log(basename +" download try block error:"+err) });
        } catch (err) {
            // displayException(err);
            console.log( basename +" download catch block error:" + err);
        }
        //success callback
        var downloadCompleted = function () {
            console.log("image full set downloaded:" + fileName)
            extractzip(fileName, tablename);    
        }
        //error callback
        var downloadFailed = function (err) {
            console.log(basename +" download  failed:" + err);
        }
        //progress callback
        var downloadProgress = function (progress) {
            console.log(basename +" bytes retrieved: " + progress.progress.bytesReceived);
        }
    };
       It works fine. sometimes the zip file downloaded completely but it doesn't entering into startAsync then function.it doesn't entering into downloadCompleted(),downloadFailed()and downloadProgress().
     download.startAsync().then(downloadCompleted, downloadFailed, downloadProgress);
    Any help would be greatly appreciated


    Monday, April 28, 2014 2:43 PM

Answers

All replies