Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 230080

File.writeFile: Not working on Android Capacitor

$
0
0

Heyo,

I am using the following code to download a file. This works on iOS without any issue.

On Android at least in the emulator on the localhost. However, after deploying to the server and running the app either in an emulator pointing to this, or a real device, an error message appears. Only on Android.

Do you have any idea how I can solve this? Thank you! :slight_smile:

    if (isPlatform('android')) {
        try {
            setTimeout(() => {
                File.removeFile(File.externalDataDirectory, filename)
            }, 2000)
        } catch (e) {
            console.log(e)
        }
        File.writeFile(File.externalDataDirectory, filename, content, true).then(success => {
            FileOpener.showOpenWithDialog(File.externalDataDirectory + filename, mimeType)
                .then(() => console.log('File opened'))
                .catch(e => toast.error("Fehler beim Öffnen der Datei: " + e));
        })
            .catch(e => toast.error("Fehler beim Speichern der Datei: " + e));
    }

Uncaught TypeError: Cannot read property 'then' of undefined


Viewing all articles
Browse latest Browse all 230080

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>