I have this code:
async function downloadMod(url, folder, basePath) {
const httpclient = await getClient();
const file = await httpclient.get(url, {
responseType: ResponseType.Binary
});
invoke("expand_scope", { folderPath: basePath }) // Used to allow writes in whatever folder i want
await writeTextFile( url.split('#')[0].split('?')[0].split('/').pop(), Uint8Array.from(file.data), { dir: BaseDirectory.Desktop });
}
How can i save the file to basePath + folder and if basePath's folder folder dosent exists create one?
Im on windows btw...
I tried using the string as the path but it didnt work, it didnt spit out an error but didnt create the file...
You can use fs plugin to create the folder recursively:
Don't forget to setup permissions inside
tauri.conf.jsonas well: