#WriteFile
16 messages · Page 1 of 1 (latest)
Thank you for your message!
1. Search the #1047150269156294677 forum for existing posts
2. Search Github issues to see if this is a known issue
3. Send the output of `tauri info`
4. Provide reproduction steps for your issue
5. Be polite and remember to follow the [Tauri Code of Conduct](https://github.com/tauri-apps/governance-and-guidance/blob/main/CODE_OF_CONDUCT.md)
Once you've read this and taken the appropriate steps, react to this message
You should put it in the app data directory, in Rust, you can get that with:
let context = tauri::generate_context!();
let config = context.config();
let dir = tauri::api::path::app_data_dir(config).expect("Can't find data directory");
saving the file is just using Rust to write the file
though you need to be careful about concurrency
this is what i used: https://gist.github.com/icambron/3b8875a882c5285bd85cca292ffb490a, which wraps up storing a json serialization of some type T (you'd need my Error type to use that directly, just giving you the idea)
The truth is that I have no idea about rust, I'm looking at how to do REACT with @tauri-apps/api/fs, I have it like this:
import { createDir, writeTextFile, BaseDirectory } from '@tauri-apps/api/fs';
const contents = {
"name": "John Doe",
"age": 30,
};
await createDir('soulbaby', { dir: BaseDirectory.AppData, recursive: true });
await writeTextFile("auth.json", JSON.stringify(contents), { dir: BaseDirectory.AppData });
And it doesn't work for me :(, do you know why it could be?
And it doesn't work for me :(, do you know why it could be?
Did you already check the devtools console? (right click -> inspect)
(maybe you need to wrap that block in a try/catch that explicitly logs errors to the console idk)
I have it in a try/catch but it still doesn't work
can you log the actual error? like add console.log(error) or include the error in the toast instead of ignoring it
the try/catch solution was not a fix but a way to make sure we get the error
Jajaja true.
The error is path not allowed on the configured scope: C:\Users\DannielTp\AppData\Roaming\com.soulbaby.app\soulbaby, so I think I know how I can fix it, I'm going to try putting the path in the scope in tauri.conf.json
Even though in scope I have $APPDATA/soulbaby/*
and it keeps giving a error