Question

I'm trying to save locally (using LocalFileSystem) a picture (I retrieve from an URL with XMLHttpRequest) with Cordova. After much investigation, I have narrowed down the problem to one point: transforming a ArrayBuffer to a Blob. This is working with Chrome on Windows (the xhr.responseType being arraybuffer):

var blob = new Blob([xhr.response], {type: 'image/jpeg'});

But it's not working with Cordova (2.9.0) on iOS (XCode iOS 6.1 simulator). Any idea?

Was it helpful?

Solution

I'm not sure Blob is actually available on Cordova. I can't find any reference in the official documentation, even if some forum discussions mention it. Anyway, i don't think Cordova is able to save a JPEG file using a Blob as for the 2.9.0 version I'm currently using.

So I have found an alternative solution to store locally a file from an URL, using FileTransfer, thanks to GitHub Gists. I adapted a snippet I have found here:

https://gist.github.com/nathanpc/2464060

So thank you, Nathan...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top