Fuse Community

Download image and save to CameraRoll

I am trying to save a remote Image to the camera roll.

I understand that to use the CameraRoll.publishImage(image) function, I need to have an image object. I am trying to firgure out how to download the image file from an URL and to get it as an image object.

Thanks in advance



Hey Frederick

The Image api needs some work to make it clearer in this regard, but to make a valid image object all you really need is an object with a valid path property, ie { path: 'path/to/my/image.png' }

Now how you get that path depends on your approach, but if you’re downloading from a URL using FuseJS/FileSystem in conjunction with XMLHttpRequest should get you there.

After playing a while here is the working script to download an image from an URL. Is this the right way to do it ?

var FileSystem = require("FuseJS/FileSystem");

var oReq = new XMLHttpRequest();
oReq.open("GET", "[IMAGE URL]", true);
oReq.responseType = "arraybuffer";

oReq.onload = function (oEvent) {
  var arrayBuffer = oReq.response; 
  if (arrayBuffer) {
    var path = FileSystem.dataDirectory + "/" + "testfile.jpg";
    FileSystem.writeBufferToFile(path, arrayBuffer);



This worked amazing for me. Thanks.
Now, how could I use that file in my UX?

this is all I could find but I can’t get it to work properly

@reverdin That is a good way of doing it. We will get fetch working soon as well.

@Luis If you have problems playing video, it would be nice if you could open a new thread with some more details.

Hello reverdin
You managed to download the image from the URL and save it on the cameraRoll

I have tried with some examples that I have found but they do not keep it on the cameraRoll

You could help me with an example, thank you

Is it possible to save that Image to the public Download Folder? Or am I doing something wrong, when the Image is not showing up in my Galery? :see_no_evil:

Thanks (=