Trouble with caching PDF to file on iOS


#1

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: " + info.total);
            debug("Free space on device: " + info.free);
        }, 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!');
                checkCachedFile(url);
            });
        },function(err){
            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;
[DEBUG] }

Nothing fancy in the config, so…

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

Cheers,
Anders


#2

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:

https://trigger.io/modules/request/current/docs/index.html