# Loading saved files from the internet does not work on device?

**URL:** <https://forums.fusetools.com/t/loading-saved-files-from-the-internet-does-not-work-on-device/7323>\
**Category:** How-to Discussions\
**Created:** [August 6, 2018, 6:53am UTC](https://forums.fusetools.com/t/loading-saved-files-from-the-internet-does-not-work-on-device/7323 "2018-08-06T06:53:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![R0b0tn1k](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/r0b0tn1k/32/49_2.png) [@R0b0tn1k](https://forums.fusetools.com/u/R0b0tn1k)\
**Post date:** [August 6, 2018, 6:53am UTC](https://forums.fusetools.com/t/loading-saved-files-from-the-internet-does-not-work-on-device/7323/1 "2018-08-06T06:53:08Z")

</div>

I’m downloading photos from the internet, saving them on the device, then displaying them.  
This works on Fuse on my Mac, but I’ve been testing it on my actual device, both on Fuse app, and compiling in XCode and deploying on the device, and it’s the same thing.

Here’s the error reported:

 ![Screen_Shot_2018-08-05_at_9_44_30_PM](https://canada1.discourse-cdn.com/flex035/uploads/fusetools1/original/1X/655dd63cf41ead816739f71e6978672d408194b7.jpg) ![55%20PM](https://canada1.discourse-cdn.com/flex035/uploads/fusetools1/original/1X/3653c4b27a0f1f19796163b250dcbd9da2e47db2.png)

Here’s how I download the files and save them:

> var oReq = new XMLHttpRequest();  
> oReq.open(“GET”, item, true);  
> oReq.responseType = “arraybuffer”;  
> oReq.onload = function (oEvent) {
> 
> var arrayBuffer = oReq.response;  
> if (arrayBuffer) {
> 
> ```
> var path = FileSystem.dataDirectory + "/" + fname.replace(" ","_");
> FileSystem.writeBufferToFile(path, arrayBuffer);
> 
> ```
> 
> }
> 
> };  
> oReq.send(null);

And here’s how I find the path to display as observable:

> var imgUrl = data.objects[i].Photo;  
> // replaces spaces with url friendly format  
> imgUrl = decodeURIComponent(imgUrl);  
> // just get the filename  
> var img = imgUrl.substring(imgUrl.lastIndexOf(‘/’)+1,imgUrl.lastIndexOf(‘.’)+4);  
> // replace spaces with underscores  
> img = img.replace(" “,”\_")  
> // create object LocalPhoto with local URL of file where it was downloaded  
> data.objects[i].LocalPhoto = FileSystem.dataDirectory + “/” + img;
> 
> ToursArr.push(data.objects[i]);

Any ideas?

---

<div class="post-metadata">

**Author:** ![Matti\_Tihverainen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/matti_tihverainen/32/684_2.png) [@Matti\_Tihverainen](https://forums.fusetools.com/u/Matti_Tihverainen)\
**Post date:** [August 6, 2018, 3:51pm UTC](https://forums.fusetools.com/t/loading-saved-files-from-the-internet-does-not-work-on-device/7323/2 "2018-08-06T15:51:57Z")

</div>

Hello! I’ve been using this on all devices successfully:

```auto
fetch("https://www.example.com/base64image.php", {
      method: "POST",
      headers: {
        "pragma": "no-cache",
        "cache-control": "no-cache"
      }
    }).then(function(response) {

      if (response.status == 200) {return response._bodyText;}

    }).then(function(data) {

      try {

        Storage.write("image.jpg", data).then(function (success) {

          if (success) {

            ImageTools.getImageFromBase64(data).then(function(image) {

              // image.path contains the path to the image

            });

          }

        });

      } catch (err) {

        // error

      }

    });

```

---

<div class="post-metadata">

**Author:** ![R0b0tn1k](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/r0b0tn1k/32/49_2.png) [@R0b0tn1k](https://forums.fusetools.com/u/R0b0tn1k)\
**Post date:** [August 11, 2018, 4:56pm UTC](https://forums.fusetools.com/t/loading-saved-files-from-the-internet-does-not-work-on-device/7323/3 "2018-08-11T16:56:44Z")

</div>

So turns out it wasnt Fuse to blame, it was my local python server, which changed IP when I changed WiFi. All is good.
