Function tauri::api::file::read_binary
source · Expand description
Reads the entire contents of a file into a bytes vector.
Examples found in repository?
src/endpoints/file_system.rs (line 139)
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
fn read_file<R: Runtime>(
context: InvokeContext<R>,
path: SafePathBuf,
options: Option<FileOperationOptions>,
) -> super::Result<Vec<u8>> {
let resolved_path = resolve_path(
&context.config,
&context.package_info,
&context.window,
path,
options.and_then(|o| o.dir),
)?;
file::read_binary(&resolved_path)
.with_context(|| format!("path: {}", resolved_path.display()))
.map_err(Into::into)
}