Trouble with caching PDF to file on iOS


Hi guys and girls!

I’m having trouble with Caching a file like this:

    var cacheFile = function (url) {
        debug('info','caching file:' + url);
        forge.file.getStorageInformation(function (info) {
            debug("Total space on device: " +;
            debug("Free space on device: " +;
        }, function (e) {
            // handle any errors
        forge.file.cacheURL(url, function (file) {
            // File cached save the file object for later
            debug('info','file fetched!');
            forge.prefs.set(url, file, function () {
                // file saved
                debug('info','file saved to prefs!');
            debug('info','caching file error:' + JSON.stringify(err));

The file is fetched OK (apparantly), but saving it gives me this error:

Returned to javascript: {
[DEBUG]     callid = "F5AE4F9B-6591-4566-8630-3154CA0D0BCA";
[DEBUG]     content =     {
[DEBUG]         message = "Unable to save to file";
[DEBUG]         subtype = "<null>";
[DEBUG]         type = "UNEXPECTED_FAILURE";
[DEBUG]     };
[DEBUG]     status = error;

Nothing fancy in the config, so…

Hope you can see what I can’t :slight_smile:



Ah, have you tried doing this with a https:// URL ?

You may need to configure an ATS exception for IOS if you’re trying to cache a http:// URL: