silkimen / cordova-plugin-advanced-http

Cordova / Phonegap plugin for communicating with HTTP servers. Allows for SSL pinning!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do I make downloaded files viewable in the iPhone's Files and Photos apps?

nomori7010 opened this issue · comments

Even if you download the image URL file with the following code, it cannot be viewed in the iPhone's Files and Photos apps. How do I do that?

await cordova.plugin.http.downloadFile(
            imageUrl,
            {},
            {},
            cordova.file.documentsDirectory+ fileName,
            // success callback
            function(entry, response) {
                console.info(entry.name + ' saved successfully.');
            },
            // error callback
            function(response) {
               console.log(response.error);
            }
        );

The iOS file system is designed to keep the document directory within the App scope. See cordova-plugin-file docu here for details: https://github.com/apache/cordova-plugin-file#where-to-store-files
You need to enable a file sharing flag and allow in-place opening of files to achieve the use-case you want. But this is not related to the usage of this plugin.
Please use StackOverflow for this kind of questions. Or just try to google for the flags I mentioned above (unfortunately forgot the exact names of those flags).