feat: share local files by path to preserve original filenames - #14
Conversation
|
Marking it as a draft until I've verified it works as expected on all platforms |
4ca4001 to
ec5daa9
Compare
Add an optional `filePaths` field to `ShareData`/`ShareOptions` that accepts absolute filesystem paths. The files are shared directly from disk on macOS, iOS, and Windows instead of being copied from Base64, keeping the original filename intact. - JS API: `ShareData.filePaths` and frontend validation. - Rust: `ShareOptions.file_paths` with combined `MAX_FILES` and `MAX_FILE_PATH_BYTES` validation. - macOS: converts paths to `NSURL` and appends them to the sharing picker items. - iOS: converts paths to `URL` and appends them to `UIActivityViewController` activity items. - Windows: uses `StorageFile::GetFileFromPathAsync` to obtain `IStorageItem`s for `DataTransferManager`. Closes sudosylabs#13
ec5daa9 to
d0e99bb
Compare
|
@AbassHammed confirmed working on all platforms (after making a few tweaks). Ready for your review! Thanks. |
|
Found an additional issue on Windows. Please stand by |
Switch `DataPackage.SetStorageItems` from `readOnly = false` to `readOnly = true` so the share target receives a read-only token for source files. This matches the standard `SetStorageItems` overload and avoids failures when a source file cannot be opened for writing by the target app. Normalize any forward slashes to Windows backslashes before calling `StorageFile::GetFileFromPathAsync`, because the WinRT API is stricter about separator style than `std::path`. Rewrite the Windows `DataRequested` handler to build the storage item vector synchronously, add a `recv_timeout` so a missing deferral does not hang forever, and parameterise `create_temp_file_for_data` by an external `temp_dir` so it can be reused by the file-path handler. Add unit tests for `create_temp_file_for_data`. Also replace `eprintln!` with `log::error!` in the temp-file cleanup and macOS logging paths, and apply `cargo fmt`.
efadd44 to
eb76d56
Compare
|
@AbassHammed Fixed! Thanks for your patience. |
|
Thanks for the update, Karl. The latest Windows approach looks good, but I found one blocker on Android.
I also noticed that this change removes |
|
@AbassHammed, thanks for the review. Both points are addressed in the latest commit:
I also added a Please re-review when you have a moment. |
…ack and restore text extras - Honor caller-declared FileProvider roots for filePaths on Android; fall back to copying files into the plugin's cache share directory when a path is outside a declared root, avoiding IllegalArgumentException. - Restore EXTRA_TEXT, EXTRA_TITLE, and EXTRA_SUBJECT for shares that include files, fixing the mixed text + file API regression. - Document the FileProvider/filePaths behavior in the README, including how consumers can declare custom roots and why a cache-path entry is still needed.
c47654b to
0404531
Compare
|
@AbassHammed any plans on completing this PR and publishing a new RC? Thanks |
Implements the optional
filePathsfield requested in #13, allowing files that already exist on disk to be shared directly while preserving the original filename.Changes
guest-js/index.ts): addedShareData.filePathswithMAX_FILE_PATH_BYTESvalidation; combinedfiles+filePathscount and size checks.src/models.rs): addedShareOptions.file_pathsandMAX_FILE_PATH_BYTES, counting file paths towardMAX_FILES.src/platform/macos.rs): appendsNSURLobjects built fromfile_pathsdirectly to theNSSharingServicePickeritems.ios/Sources/SharePlugin.swift&ShareCore): appendsURL(fileURLWithPath:)objects fromfilePathstoUIActivityViewController, and validatesfilePathslength on the Swift side.src/platform/windows.rs): resolvesStorageFilefrom eachfile_pathsentry viaGetFileFromPathAsyncand adds theIStorageItemtoDataTransferManager.filePathsoption in both TypeScript and Rust examples.file_pathsfield; regeneratedapi-iife.jsanddist-js.Verification
cargo +1.89.0-aarch64-apple-darwin test— 11 passedcargo +1.89.0-aarch64-apple-darwin fmt --check— cleancd ios && VNIDROP_SHARE_USE_TAURI_STUB=1 swift test— 5 passednpm run build—dist-js+api-iife.jsregeneratednpm run test— 8 passednpm run test:types— cleanCloses #13