Skip to content

Conversation

@ivan-vanyusho
Copy link

@ivan-vanyusho ivan-vanyusho commented Jan 20, 2026

Description

Changed iOS file storage path from documentDirectory to temporaryDirectory to ensure consistency with Android where files are stored in cache directory.

Changes

  • iOS now uses temporaryDirectory instead of documentDirectory for consistency with Android

Code changes

// Before:
let documentDirectory = FileManager.default.urls(
      for: .documentDirectory,
      in: .userDomainMask)[0]

// After:
let documentDirectory = FileManager.default.temporaryDirectory

Issues

flutter/flutter#166933

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly changes the iOS file storage path from documentDirectory to temporaryDirectory to align with Android's behavior, improving cross-platform consistency. I have one suggestion to improve code clarity by renaming a variable that became misleading due to this change.

@stuartmorgan-g
Copy link
Collaborator

Thanks for the submission! This will need the remaining items in the checklist addressed before it moves forward with review. If you have any questions about completing those steps that aren’t addressed in the linked documentation, please let us know.

@stuartmorgan-g stuartmorgan-g marked this pull request as draft January 20, 2026 12:54
@ivan-vanyusho ivan-vanyusho marked this pull request as ready for review January 22, 2026 14:08
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request updates the iOS camera plugin to store captured pictures and videos in the system's temporaryDirectory instead of the application's documentDirectory. This change aligns the iOS behavior with Android's cache directory usage. The CHANGELOG.md has been updated to reflect this as a breaking change, and the pubspec.yaml version has been incremented accordingly.

Copy link
Collaborator

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs tests before it can be reviewed, per the checklist.

@@ -1,3 +1,8 @@
## 0.9.23

* **BREAKING CHANGES**:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what scenario specifically are existing applications broken by this change? What action do package clients need to take?

If this does in fact need to be a breaking change, it will require correct versioning, and a cascading breaking change to camera, so would need significant discussion.

@ivan-vanyusho ivan-vanyusho marked this pull request as ready for review January 26, 2026 14:13
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully updates the iOS file storage path for camera pictures and videos from the application's documentDirectory to the temporaryDirectory, aligning with Android's cache directory usage for consistency. The change is well-supported by a new test case that verifies the updated storage location. The CHANGELOG.md and pubspec.yaml files have been updated appropriately.

}

func testCaptureToFile_mustSavePhotoToCameraPicturesDirectory() {
let expectedPath = "/tmp/camera/pictures/"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The expectedPath is hardcoded as "/tmp/camera/pictures/". While this is correct for the current implementation, it could be more robust to derive this path dynamically within the test, perhaps by calling the same utility function that constructs the path in DefaultCamera.swift (if exposed or mockable), or by inspecting FileManager.default.temporaryDirectory and appending the known subpaths. This would make the test less brittle if the subfolder structure changes in the future.

@stuartmorgan-g stuartmorgan-g added the triage-ios Should be looked at in iOS triage label Jan 27, 2026
Copy link
Contributor

@hellohuanlin hellohuanlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS now uses temporaryDirectory instead of documentDirectory for consistency with Android

I don't see why we want this "consistency". Apple's recommendation is to use documentDirectory for user generated files (so that it could be exported when connected to mac).

To fix the broken file, we could either (1) save to temp directory first, and move to document directory once done, or (2) save to document directory, and delete if error happens.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants