Skip to content

feat(core): add convert_file_src() — Rust equivalent of convertFileSrc()#14951

Closed
omair445 wants to merge 1 commit intotauri-apps:devfrom
omair445:feat/convert-file-src-rust
Closed

feat(core): add convert_file_src() — Rust equivalent of convertFileSrc()#14951
omair445 wants to merge 1 commit intotauri-apps:devfrom
omair445:feat/convert-file-src-rust

Conversation

@omair445
Copy link

Hey! I noticed there's no Rust-side equivalent of the JS convertFileSrc() function, so I went ahead and added one.

What this does

Adds a public tauri::convert_file_src() function that converts a local file path into an asset protocol URL that can be loaded by the webview. This mirrors the existing JavaScript convertFileSrc() behavior:

  • Windows/Android: https://{protocol}.localhost/{encoded_path}
  • macOS/Linux/iOS: {protocol}://localhost/{encoded_path}

Usage

// Default 'asset' protocol
let url = tauri::convert_file_src("/path/to/image.png", None);

// Custom protocol
let url = tauri::convert_file_src("/path/to/file.mp4", Some("stream"));

This is useful for Rust plugin authors and app developers who need to construct asset URLs from the backend without going through JS.

Closes #12022

Adds a public convert_file_src() function to the tauri crate that converts
local file paths to asset protocol URLs, matching the behavior of the
existing JavaScript convertFileSrc() function.

On Windows/Android: https://{protocol}.localhost/{encoded_path}
On other platforms: {protocol}://localhost/{encoded_path}

Closes tauri-apps#12022
@omair445 omair445 requested a review from a team as a code owner February 15, 2026 16:42
@github-project-automation github-project-automation bot moved this to 📬Proposal in Roadmap Feb 15, 2026
@omair445
Copy link
Author

Hey everyone, I am very very sorry I got stuck in work-related stuff and haven't been able to follow up on this. I am happy if anyone else can take care of this from here or if the maintainers want to push the final bits. Apologies again for the delay!

@Legend-Master
Copy link
Contributor

Hey, thanks for contributing.

I am closing this since someone's already working on this at #14786 and the review is in progress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📬Proposal

Development

Successfully merging this pull request may close these issues.

[feat] Rust equivalent convertFileSrc()

2 participants