Background Downloader to localStorage file empty lost connection RRS feed

  • Question

  • Working on Windows 8 HTML5/JavaScript app and trying to download files to localFolder while online and reference said files when offline.  When I use the background transfer method, with the uri as my url for server images, I'm able to create the storage file and populate with my image using the downloader with no issues.  However, when I lose connection, the storage file becomes empty as the uri is lost, behaving more like a streamed source.  It seems this defeats the purpose of using the transfer.  It should write to the storage file, correct?

    var downloadOperation = backgroundDownloader.createDownload(uri, resultFile, requestBodyFile);

    I'm trying to use this as a cache method since I am not using iFrames with the browser built in appCache. 


    • Edited by hxnwx Wednesday, March 11, 2015 5:08 PM
    Wednesday, March 11, 2015 5:07 PM


All replies

  • Hi Hxnwx,

    You used background downloader to retrieve images, this worked when computer network online. But the image could not display when computer network offline, is it right? Per my understanding, when app success in downloading the picture, it will in storage. Have you checked the image in local storage when connect lost? Was the image empty in this case?

    Please try this MSDN sample to see if the problem is persists. https://code.msdn.microsoft.com/windowsapps/Background-Transfer-Sample-d7833f61#content.

    By the way, if you want to download the small resource that are likely to complete quickly, you should use HttpClient API instead of background downloader. See note section from the following reference. https://msdn.microsoft.com/en-us/library/windows/apps/hh452979.aspx.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, March 12, 2015 5:34 AM
  • Yes.  This is exactly what happened.  The image immediately became empty when I disconnected.  I went with background transfer because I have many images (close to 100).  I've been able to use the WinJS.xhr call to download the images with no problem.  And I can create the storage files with no problem.  My trouble is saving the downloaded images to the local folder.  What am I missing?  
    Thursday, March 12, 2015 10:50 AM
  • Found out what I needed here:  Writing to newly created file with msStream.


    Thursday, March 12, 2015 5:24 PM