I still have the same error, it tells me that the file is damaged when opening the excel with the android application. This only happens when I save it with writeFile, because if I transfer the file that is in s3 to the phone and open it originally, it opens correctly
import { FileOpener } from '@capacitor-community/file-opener';
import { Directory, Filesystem,Encoding, } from '@capacitor/filesystem';
interface CustomFile {
title: string,
url: string,
mineType: string
}
const openLink = async (file: CustomFile) => {
try {
const response = await fetch(file.url);
const blob = await response.blob();
const base64data = await convertBlobToBase64(blob)
const savedFile = await Filesystem.writeFile({
path: file.title,
data: base64data,
directory: Directory.Documents,
// encoding: Encoding.UTF8,
// recursive: true
});
await FileOpener.open({
filePath: savedFile.uri,
contentType: file.mineType,
})
} catch (error) {
console.error(error);
}
};
const convertBlobToBase64 = (blob: Blob) : Promise<string> => new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onerror = reject;
reader.onload = () => {
resolve(reader.result as string)
}
reader.readAsDataURL(blob);
})
openLink({
title: 'gestion_0HV9WdBxQ1.xlsx',
url: 'https://laguagua-bucket-br.s3.sa-east-1.amazonaws.com/informes/items/gestion_0HV9WdBxQ1.xlsx',
mineType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
});
Excel App Mobile message:
We have encountered a problem with some of the content of âgestion_0HV9WdBxQ1.xlsxâ. Do you want us to try to recover as much as possible? If you trust the origin of this book, click yes
and something strange happens, that file is saved in my documents obviously on my android phone. What I do to test that file is search for it and then I try to send it to myself by WhatsApp and WhatsApp tells me âthe selected file was not a document.â To test another case, I located that file written by FilesystemwriteFile and took it to my computer to open it with Microsoft Excel Online and when I try to open it it throws an error
{
âmistakeâ: {
âcodeâ: 400,
âmessageâ: âConversion of the uploaded content to the requested output type is not supported.â,
âerrorsâ: [
{
âmessageâ: âConversion of the uploaded content to the requested output type is not supported.â,
âdomainâ: âglobalâ,
âreasonâ: âconversionUnsupportedConversionPathâ
}
]
}
}