Open barribarrier opened 2 weeks ago
I'm hitting this too on macOS with the same package versions. Similarly, writeTextFile
worked fine.
export const downloadFile = async (
filename: string,
content: string | Uint8Array,
_mimeType: string,
) => {
if (typeof content === 'string') {
await writeTextFile(filename, content, { baseDir: BaseDirectory.Download });
} else {
await writeFile(filename, content, { baseDir: BaseDirectory.Download });
}
};
Cargo.toml
tauri-plugin-fs = "2.0.0-beta.9"
package.json
"@tauri-apps/plugin-fs": "2.0.0-beta.5",
Turns out you need to enable "linux-ipc-protocol" feature in your Cargo.toml in order to send binary data on Linux. https://github.com/tauri-apps/tauri/blob/3bbfac8f3ba9363fb267bf353687f01884d48924/core/tauri/scripts/ipc-protocol.js#L20
I had the same problem as you when I was saving an excel file.
Error:
unexpected invoke body
I am sure that I get the correct http response body, but I can not save it as a file.
My code:
axios.get(url, {
responseType: 'arraybuffer',
}).then((response) => {
writeFile(savePath, response.data);
});
But when I save a image by using above code, it is correct. I am very confused about this.
writeFile
is failing on Linux.I call it like this:
Error:
writeTextFile
worked fine though.package.json
"@tauri-apps/plugin-fs": "^2.0.0-beta.5"
cargo.toml
tauri-plugin-fs = "2.0.0-beta.9"
permissions:
"fs:allow-write", "fs:allow-write-file", "fs:allow-write-text-file",