"Filesystem" plugin is not implemented on android

I want to download images in my project which should store in the device, so I have used FIlesystem in that. here I am getting the image data from the server (in the form of URL ), I have converted this image Url to base64Data but I am getting an error of “Filesystem plugin is not implemented on android.”

Error: “Filesystem” plugin is not implemented on android

below I am providing my code:
downloadFile(){
this.saveToMobileStorage(this.base64Data, ‘yourFileName.jpg’);
}
async saveToMobileStorage(base64Data: string, fileName: string) {
try {
const blobData = this.base64toBlob(base64Data);
const base64String = URL.createObjectURL(blobData);

const dataDirectory = Directory.Data;
const fileWriteOptions:any = {
  path: fileName,
  data: base64String,
  directory: dataDirectory,
};

await Filesystem.writeFile(fileWriteOptions);

console.log('File saved successfully.');

} catch (error) {
console.error(‘Failed to save the file:’, error);
}
}

base64toBlob(base64Data: string): Blob {
const byteCharacters = atob(base64Data);
const byteArrays = ;
for (let offset = 0; offset < byteCharacters.length; offset += 512) {
const slice = byteCharacters.slice(offset, offset + 512);
const byteNumbers = new Array(slice.length);
for (let i = 0; i < slice.length; i++) {
byteNumbers[i] = slice.charCodeAt(i);
}
const byteArray = new Uint8Array(byteNumbers);
byteArrays.push(byteArray);
}
return new Blob(byteArrays, { type: ‘image/jpeg’ }); // Adjust the MIME type according to your data.
}

can anyone please help me out of this

Thanks

Please use proper code blocks :slight_smile:

You are using the official Capacitor Filesystem plugin?

yes I am using the offical filesystem

Did you run npx cap sync after installing the Capacitor plugin on the terminal?

Having the same issue here as well. In my case im using downloadFile.

Do we need to manually install “@capacitor/filesystem”: “^5.1.2”,

yeah install manually and try it worked for me.

I am also getting the same error but on android apk.

I build my project then sync it with android then build apk file and when try to select any images it shows “Filesystem” plugin is not implemented on android

The same code works fine on pc and also used on inspect mobile tool, the error is only occuring when I build a apk file.

I have used Filesystem.writeFile method to save the images which saves as blob.

can someone please help me through out this.