Fix: Use PHP-accessible, persistent storage for captured media (Android + iOS) - #12
Open
sonalidudhia wants to merge 2 commits into
Open
Conversation
added 2 commits
August 24, 2026 12:14
- Changed photo capture to save to context.filesDir/Camera instead of context.cacheDir - Updated video recording to use the same accessible directory - Updated gallery picker (single and multiple) to save to context.filesDir/Gallery - This fixes the issue where PhotoTaken event returned paths in private Android cache that PHP cannot access (e.g., /data/user/0/com.domain.app/cache/) - Now PHP can properly read captured photos and videos using file_get_contents() and Storage::put() operations Fixes NativePHP#8
- Photo, video, and gallery captures now save to Application Support/Camera and Application Support/Gallery instead of NSTemporaryDirectory() - NSTemporaryDirectory() can be purged by iOS at any time (low disk space, relaunch, etc), risking the same class of 'file went missing before PHP could read it' failure as Android's cache dir (Issue NativePHP#8) - Application Support is private and persistent (never auto-purged), matching the fix already applied on Android (cacheDir -> filesDir) - isExcludedFromBackup is unaffected -- captures still won't bloat iCloud/iTunes backups Related to NativePHP#8
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #8
Problem
On Android,
PhotoTakenreturned a path insidecontext.cacheDir(/data/user/0/<pkg>/cache/...) that PHP could not read viafile_exists()/file_get_contents().Fix
context.filesDir/Cameraandcontext.filesDir/Galleryinstead ofcacheDir.NSTemporaryDirectory(), which iOS can purge at any time. Captures now save toApplication Support/Cameraand/Galleryinstead, matching Android's persistent-storage approach.isExcludedFromBackupis preserved so backups aren't bloated.Testing
Verified on a Laravel/NativePHP app (Android emulator + physical device): captured photo path now resolves under
files/Camera/..., andfile_exists(),file_get_contents(), andStorage::put()all succeed against the returned path.