Hi, everyone
We’re trying to write files to devices with our Ionic Vue project.
But unfortunately we cannot get it to work in device on both platform using the code below:
import { Plugins, FilesystemDirectory, FilesystemEncoding } from '@capacitor/core'
const { Filesystem } = Plugins
export default {
writeFile({ uid, file }) {
try {
return Filesystem.writeFile({
path: `${uid}.txt`,
data: file,
directory: FilesystemDirectory.Documents,
encoding: FilesystemEncoding.UTF8
})
} catch (e) {
alert('Error: file write: ' + JSON.stringify(e))
return Promise.reject(e)
}
}
}
It is working fine on browser but not on devices. No error message is given as it doesn’t call alert()
in catch block and the Filesystem.writeFile()
doesn’t resolve or reject to anything.
File content is a big base64 string and file size is 10M+. We tried to write blob to file earlier, but faced with same problem.
Also storage permission for device is granted.
Any help or guidance would be very much appreciated, thanks.