hi
I have used background download transfer to download zip files,i have called zipextraction function
function DownloadOperation() {
var download = null;
var promise = null;
this.start = function (uri, destFolder, fileName, priority, requestUnconstrainedDownload) {
var ext = fileName.substr(fileName.lastIndexOf('.'));
if (ext.localeCompare(".zip") != 0) {
displayError("Invalid file type. Please make sure the file type is zip.", NotifyType.ErrorMessage);
return;
}
// Asynchronously create the file in the pictures folder.
destFolder.createFileAsync(fileName, Windows.Storage.CreationCollisionOption.generateUniqueName).done(function (localFile) {
var downloader = new Windows.Networking.BackgroundTransfer.BackgroundDownloader();
// Create a new download operation.
download = downloader.createDownload(uri, localFile);
Log("Downloading " + uri.absoluteUri.toString() + "to " + destFolder.name + "with " + priority + " priority, " + download.guid);
download.priority = priority;
// In this sample, we do not show how to request unconstrained download.
// For more information about background transfer, please refer to the SDK Background transfer sample:
// http://code.msdn.microsoft.com/windowsapps/Background-Transfer-Sample-d7833f61
if (!requestUnconstrainedDownload) {
// Start the download and persist the promise to be able to cancel the download.
promise = download.startAsync().then(complete, error, progress);
promise.done(function () {
if (download.progress.status === Windows.Networking.BackgroundTransfer.BackgroundTransferStatus.canceled) {
LogStatus("Canceled: " + download.Guid, NotifyType.StatusMessage);
return;
}
//zip extraction
var zipFileName = fileName.substr(0, fileName.lastIndexOf('.'));
destFolder.createFolderAsync(zipFileName, Windows.Storage.CreationCollisionOption.generateUniqueName).done(function (unzipFolder) {
// Call C# compent to unzip the specified zipfile to a folder
upZipFile(localFile, unzipFolder);
});
});
return;
}
}, error);
};
// On application activation, reassign callbacks for a download
// operation persisted from previous application state.
this.load = function (loadedDownload) {
download = loadedDownload;
promise = download.attachAsync().then(complete, error, progress);
};
}
when i restart my app getcurrentdownloadASync working fine,this.load function reassign the callbacks to download but where to call extraction method when i reattach my transfer download,how to pass the arguements to this.load() function
Windows.Networking.BackgroundTransfer.BackgroundDownloader.getCurrentDownloadsAsync().done(function (downloads) {
// If downloads from previous application state exist, reassign callbacks and persist to global array.
if (downloads) {
Log("Loading background downloads: " + downloads.size);
console.log("download size:" + downloads.size);
for (var i = 0; i < downloads.size; i++) {
var download = new DownloadOperation();
download.load(downloads[i]);
downloadOperations.push(download);
}
}
});
Any help would be greatly appreciated