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:
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?