Hi there,
I’m completely new to capacitor, so beare with me.
Currently I’m trying to download a binary file (Sqlite database) and store it in the database folder. For storing I intend to use the blobwriter plugin which accepts a pure binary file only. Handing over the data of the response to blobwriter does not work, I get a file of size 0.
As the data in the response is of type “string” and its size is larger than that of the binary file, I suspected that the data is base64 encoded, however decoding by atob throws an error “wrong format”. Now I’m helpless.
Before I tried to use the Filesystem plugin but no success either. Therefore I switched to blobwriter.
My javascript:
try {
Capacitor.Plugins.Filesystem.requestPermissions().then((status) => {
console.log(status);
Capacitor.Plugins.CapacitorHttp.get({
url: 'https://webentwicklung.ulrichbangert.de/_benni/substanzen-electron/Substances.db',
responseType: 'blob'
}).then(function ({ data }) {
console.log(data.length);
window.capacitor_blob_writer({
path: 'file:///data/user/0/com.substanzen.app/databases/SubstancesSQLite.db',
data: data.data,
fast_mode: true
});
});
});
} catch (err) {
console.log(`Error: ${err} `);
throw new Error(`Error: ${err}`)
}
This runs without throwing errors, however the resulting file in the database folder is empty.
Thanks in advance for your support!
Best regards, Ulrich