From f6b6cfb3d56a84b98cf6b6c1c36a471bb2a1f375 Mon Sep 17 00:00:00 2001 From: Loewy Date: Fri, 19 Dec 2025 12:55:41 -0800 Subject: [PATCH] strip file prefix --- .../java/com/mrousavy/camera/core/RecordingSession.kt | 3 ++- package/ios/Core/CameraSession+Video.swift | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/package/android/src/main/java/com/mrousavy/camera/core/RecordingSession.kt b/package/android/src/main/java/com/mrousavy/camera/core/RecordingSession.kt index 1d61188..719709d 100644 --- a/package/android/src/main/java/com/mrousavy/camera/core/RecordingSession.kt +++ b/package/android/src/main/java/com/mrousavy/camera/core/RecordingSession.kt @@ -38,7 +38,8 @@ class RecordingSession( data class Video(val path: String, val durationMs: Long, val size: Size) - private val outputPath: File = File(filePath) + // Normalize path - expo-file-system passes file:// URIs but File expects raw paths + private val outputPath: File = File(filePath.removePrefix("file://")) private val bitRate = getBitRate() private val recorder = ChunkedRecordingManager.fromParams( diff --git a/package/ios/Core/CameraSession+Video.swift b/package/ios/Core/CameraSession+Video.swift index 825b432..35b414b 100644 --- a/package/ios/Core/CameraSession+Video.swift +++ b/package/ios/Core/CameraSession+Video.swift @@ -20,6 +20,9 @@ extension CameraSession { onError: @escaping (_ error: CameraError) -> Void) { // Run on Camera Queue CameraQueues.cameraQueue.async { + // Normalize path - expo-file-system passes file:// URIs but FileManager expects raw paths + let normalizedPath = filePath.hasPrefix("file://") ? String(filePath.dropFirst(7)) : filePath + let start = DispatchTime.now() ReactLogger.log(level: .info, message: "Starting Video recording...") @@ -98,20 +101,20 @@ extension CameraSession { } } - if !FileManager.default.fileExists(atPath: filePath) { + if !FileManager.default.fileExists(atPath: normalizedPath) { do { - try FileManager.default.createDirectory(atPath: filePath, withIntermediateDirectories: true) + try FileManager.default.createDirectory(atPath: normalizedPath, withIntermediateDirectories: true) } catch { onError(.capture(.createRecordingDirectoryError(message: error.localizedDescription))) return } } - ReactLogger.log(level: .info, message: "Will record to temporary file: \(filePath)") + ReactLogger.log(level: .info, message: "Will record to temporary file: \(normalizedPath)") do { // Create RecordingSession for the temp file - let recordingSession = try RecordingSession(outputDiretory: filePath, + let recordingSession = try RecordingSession(outputDiretory: normalizedPath, fileType: options.fileType, onChunkReady: onChunkReady, onChunkError: onChunkError,