feat(io): add write_bytes command for binary exports

This commit is contained in:
pj committed 2026-06-20 12:55:48 -04:00
1 parent aedf8b8a63
commit 4443eda401
2 files changed
+10 -1

No files matched your search

+2 -1
View File
@@ -9,7 +9,8 @@ pub fn run() {
.invoke_handler(tauri::generate_handler![
pdf::compile_pdf,
project::read_file,
project::write_file
project::write_file,
project::write_bytes
])
.run(tauri::generate_context!())
.expect("error while running margin");
+8
View File
@@ -1,3 +1,5 @@
use base64::Engine;
use base64::engine::general_purpose::STANDARD;
use std::fs;
#[tauri::command]
@@ -9,3 +11,9 @@ pub fn read_file(path: String) -> Result<String, String> {
pub fn write_file(path: String, contents: String) -> Result<(), String> {
fs::write(&path, contents).map_err(|e| e.to_string())
}
#[tauri::command]
pub fn write_bytes(path: String, data: String) -> Result<(), String> {
let bytes = STANDARD.decode(data.as_bytes()).map_err(|e| e.to_string())?;
fs::write(&path, bytes).map_err(|e| e.to_string())
}