silkimen / cordova-plugin-advanced-http

Cordova / Phonegap plugin for communicating with HTTP servers. Allows for SSL pinning!
MIT License
391 stars 313 forks source link

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

Closed nomori7010 closed 11 months ago

nomori7010 commented 11 months ago

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);
            }
        );
silkimen commented 11 months ago

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).