Use Copy instead of Move in FileSaver UI on iOS#2981
Merged
TheCodeTraveler merged 26 commits intoCommunityToolkit:mainfrom Jan 8, 2026
Merged
Use Copy instead of Move in FileSaver UI on iOS#2981TheCodeTraveler merged 26 commits intoCommunityToolkit:mainfrom
Copy instead of Move in FileSaver UI on iOS#2981TheCodeTraveler merged 26 commits intoCommunityToolkit:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the FileSaver implementation for macOS and iOS by correctly configuring the UIDocumentPickerViewController to treat the operation as saving a new file rather than copying an existing one.
- Updates the
UIDocumentPickerViewControllerconstructor call to include theasCopy: trueparameter - Ensures the OS properly handles moving temporary files to user-selected locations during save operations
src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverImplementation.macios.cs
Outdated
Show resolved
Hide resolved
Ensures temporary directory used by the file picker is always removed after the file selection is made, regardless of success or failure. Also improves error handling when a view controller cannot be retrieved. Fixes CommunityToolkit#2460
src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverImplementation.macios.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverImplementation.macios.cs
Show resolved
Hide resolved
Ensures temporary directory used by the file picker is correctly removed on iOS. Moves the directory removal to the completion handler of the view controller presentation, ensuring it's executed after the picker is dismissed. Handles exceptions during file removal by re-throwing them after attempting to remove the temporary directory.
src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverImplementation.macios.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverImplementation.macios.cs
Show resolved
Hide resolved
…mplementation.macios.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverImplementation.macios.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.Core/Essentials/FolderPicker/FolderPickerImplementation.macios.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.Core/Essentials/FolderPicker/FolderPickerImplementation.macios.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverImplementation.macios.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverImplementation.macios.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverImplementation.macios.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverImplementation.macios.cs
Outdated
Show resolved
Hide resolved
VladislavAntonyuk-AccuReference
approved these changes
Jan 6, 2026
VladislavAntonyuk
previously approved these changes
Jan 6, 2026
src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverImplementation.macios.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.Core/Essentials/FolderPicker/FolderPickerImplementation.macios.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.Core/Essentials/FolderPicker/FolderPickerImplementation.macios.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.Core/Essentials/FileSaver/FileSaverResult.shared.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.Core/Essentials/FolderPicker/FolderPickerResult.shared.cs
Outdated
Show resolved
Hide resolved
Copy instead of Move in FileSaver UI on iOS
…t `.WaitAsync()`
TheCodeTraveler
previously approved these changes
Jan 8, 2026
Collaborator
TheCodeTraveler
left a comment
There was a problem hiding this comment.
Thanks @matt-goldman!
TheCodeTraveler
approved these changes
Jan 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
Updates the
FileSavermaciOS implementation to use the newasCopyargument in theUIDocumentPickerViewControllerto tell the OS that you're saving a new file (not copying) when moving the temp file out of the sandobx to the users' desired location.Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information
Only affects macOS and iOS. Screenshots show the resultant change on a physical iOS device: