From 27bf1b683a866224d67bac2ff1a99af51d89edd3 Mon Sep 17 00:00:00 2001 From: OS-pedrogustavobilro Date: Wed, 21 Jan 2026 15:09:33 +0000 Subject: [PATCH 1/7] chore: update example app dependencies --- .../android/capacitor.settings.gradle | 6 +-- .../example-app-capacitor/ios/App/Podfile | 10 ++--- .../ios/App/Podfile.lock | 40 +++++++++---------- packages/example-app-capacitor/package.json | 4 +- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/packages/example-app-capacitor/android/capacitor.settings.gradle b/packages/example-app-capacitor/android/capacitor.settings.gradle index 33359be..e0cb898 100644 --- a/packages/example-app-capacitor/android/capacitor.settings.gradle +++ b/packages/example-app-capacitor/android/capacitor.settings.gradle @@ -1,12 +1,12 @@ // DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN include ':capacitor-android' -project(':capacitor-android').projectDir = new File('../../../node_modules/.pnpm/@capacitor+android@8.0.0-beta.0_@capacitor+core@8.0.0-beta.0/node_modules/@capacitor/android/capacitor') +project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor') include ':capacitor-camera' -project(':capacitor-camera').projectDir = new File('../../../node_modules/.pnpm/@capacitor+camera@8.0.0-beta.0_@capacitor+core@8.0.0-beta.0/node_modules/@capacitor/camera/android') +project(':capacitor-camera').projectDir = new File('../node_modules/@capacitor/camera/android') include ':capacitor-splash-screen' -project(':capacitor-splash-screen').projectDir = new File('../../../node_modules/.pnpm/@capacitor+splash-screen@8.0.0-beta.0_@capacitor+core@8.0.0-beta.0/node_modules/@capacitor/splash-screen/android') +project(':capacitor-splash-screen').projectDir = new File('../node_modules/@capacitor/splash-screen/android') include ':capacitor-filesystem' project(':capacitor-filesystem').projectDir = new File('../../capacitor-plugin/android') diff --git a/packages/example-app-capacitor/ios/App/Podfile b/packages/example-app-capacitor/ios/App/Podfile index 3240b73..fb2a939 100644 --- a/packages/example-app-capacitor/ios/App/Podfile +++ b/packages/example-app-capacitor/ios/App/Podfile @@ -1,4 +1,4 @@ -require_relative '../../../../node_modules/.pnpm/@capacitor+ios@8.0.0-beta.0_@capacitor+core@8.0.0-beta.0/node_modules/@capacitor/ios/scripts/pods_helpers' +require_relative '../../node_modules/@capacitor/ios/scripts/pods_helpers' platform :ios, '15.0' use_frameworks! @@ -9,10 +9,10 @@ use_frameworks! install! 'cocoapods', :disable_input_output_paths => true def capacitor_pods - pod 'Capacitor', :path => '../../../../node_modules/.pnpm/@capacitor+ios@8.0.0-beta.0_@capacitor+core@8.0.0-beta.0/node_modules/@capacitor/ios' - pod 'CapacitorCordova', :path => '../../../../node_modules/.pnpm/@capacitor+ios@8.0.0-beta.0_@capacitor+core@8.0.0-beta.0/node_modules/@capacitor/ios' - pod 'CapacitorCamera', :path => '../../../../node_modules/.pnpm/@capacitor+camera@8.0.0-beta.0_@capacitor+core@8.0.0-beta.0/node_modules/@capacitor/camera' - pod 'CapacitorSplashScreen', :path => '../../../../node_modules/.pnpm/@capacitor+splash-screen@8.0.0-beta.0_@capacitor+core@8.0.0-beta.0/node_modules/@capacitor/splash-screen' + pod 'Capacitor', :path => '../../node_modules/@capacitor/ios' + pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios' + pod 'CapacitorCamera', :path => '../../node_modules/@capacitor/camera' + pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen' pod 'CapacitorFilesystem', :path => '../../../capacitor-plugin' end diff --git a/packages/example-app-capacitor/ios/App/Podfile.lock b/packages/example-app-capacitor/ios/App/Podfile.lock index 6847e63..344b4b1 100644 --- a/packages/example-app-capacitor/ios/App/Podfile.lock +++ b/packages/example-app-capacitor/ios/App/Podfile.lock @@ -1,22 +1,22 @@ PODS: - - Capacitor (8.0.0-beta.0): + - Capacitor (8.0.1): - CapacitorCordova - - CapacitorCamera (8.0.0-beta.0): + - CapacitorCamera (8.0.0): - Capacitor - - CapacitorCordova (8.0.0-beta.0) - - CapacitorFilesystem (8.0.0-next.3): + - CapacitorCordova (8.0.1) + - CapacitorFilesystem (8.0.0): - Capacitor - IONFilesystemLib (~> 1.0.1) - - CapacitorSplashScreen (8.0.0-beta.0): + - CapacitorSplashScreen (8.0.0): - Capacitor - IONFilesystemLib (1.0.1) DEPENDENCIES: - - "Capacitor (from `../../../../node_modules/.pnpm/@capacitor+ios@8.0.0-beta.0_@capacitor+core@8.0.0-beta.0/node_modules/@capacitor/ios`)" - - "CapacitorCamera (from `../../../../node_modules/.pnpm/@capacitor+camera@8.0.0-beta.0_@capacitor+core@8.0.0-beta.0/node_modules/@capacitor/camera`)" - - "CapacitorCordova (from `../../../../node_modules/.pnpm/@capacitor+ios@8.0.0-beta.0_@capacitor+core@8.0.0-beta.0/node_modules/@capacitor/ios`)" + - "Capacitor (from `../../node_modules/@capacitor/ios`)" + - "CapacitorCamera (from `../../node_modules/@capacitor/camera`)" + - "CapacitorCordova (from `../../node_modules/@capacitor/ios`)" - CapacitorFilesystem (from `../../../capacitor-plugin`) - - "CapacitorSplashScreen (from `../../../../node_modules/.pnpm/@capacitor+splash-screen@8.0.0-beta.0_@capacitor+core@8.0.0-beta.0/node_modules/@capacitor/splash-screen`)" + - "CapacitorSplashScreen (from `../../node_modules/@capacitor/splash-screen`)" SPEC REPOS: trunk: @@ -24,24 +24,24 @@ SPEC REPOS: EXTERNAL SOURCES: Capacitor: - :path: "../../../../node_modules/.pnpm/@capacitor+ios@8.0.0-beta.0_@capacitor+core@8.0.0-beta.0/node_modules/@capacitor/ios" + :path: "../../node_modules/@capacitor/ios" CapacitorCamera: - :path: "../../../../node_modules/.pnpm/@capacitor+camera@8.0.0-beta.0_@capacitor+core@8.0.0-beta.0/node_modules/@capacitor/camera" + :path: "../../node_modules/@capacitor/camera" CapacitorCordova: - :path: "../../../../node_modules/.pnpm/@capacitor+ios@8.0.0-beta.0_@capacitor+core@8.0.0-beta.0/node_modules/@capacitor/ios" + :path: "../../node_modules/@capacitor/ios" CapacitorFilesystem: :path: "../../../capacitor-plugin" CapacitorSplashScreen: - :path: "../../../../node_modules/.pnpm/@capacitor+splash-screen@8.0.0-beta.0_@capacitor+core@8.0.0-beta.0/node_modules/@capacitor/splash-screen" + :path: "../../node_modules/@capacitor/splash-screen" SPEC CHECKSUMS: - Capacitor: cdbe01d8f7b542b2750fb51e88051e764b3cbc4e - CapacitorCamera: 7ff9e46889cbd3bba2ed0a4192d40f91bd1b5f05 - CapacitorCordova: 65a0b71358d76bdeb799f45cd0214d68fbe2fd56 - CapacitorFilesystem: 744a5be26e8f658c60a149401dff136ede834bb8 - CapacitorSplashScreen: ab1ec150884e35c67c7709c907b3db3a376b9956 + Capacitor: ff35b0f66370b84aa238251b35b91886a3207c16 + CapacitorCamera: 592acb7ab9fb748e2d8571eb03af30ec4e1ace12 + CapacitorCordova: 0d65b9bb74e995dcecb9463f34f1af2aba6f955c + CapacitorFilesystem: bb9d1efbf934a3c161425e2415b9baf539cdfac3 + CapacitorSplashScreen: 422880d7117605c30699eb4b21644b62db42e86c IONFilesystemLib: 89258b8e3e85465da93127d25d7ce37f977e8a6f -PODFILE CHECKSUM: bcc6c8bf6cebbd15c772e65f0a0c65a41e700610 +PODFILE CHECKSUM: f9801285586b6499bc9e372b1475a3f09f847217 -COCOAPODS: 1.16.2 +COCOAPODS: 1.14.3 diff --git a/packages/example-app-capacitor/package.json b/packages/example-app-capacitor/package.json index 7a11331..a4a5914 100644 --- a/packages/example-app-capacitor/package.json +++ b/packages/example-app-capacitor/package.json @@ -14,10 +14,10 @@ }, "dependencies": { "@capacitor/android": "^8.0.0", - "@capacitor/camera": "^7.0.0 || ^8.0.0", + "@capacitor/camera": "^8.0.0", "@capacitor/core": "^8.0.0", "@capacitor/ios": "^8.0.0", - "@capacitor/splash-screen": "^7.0.0 || ^8.0.0", + "@capacitor/splash-screen": "^8.0.0", "@capacitor/filesystem": "file:../capacitor-plugin" }, "devDependencies": { From b0f32d9200dd42e0a459b5ae01fb526c441d6fe3 Mon Sep 17 00:00:00 2001 From: OS-pedrogustavobilro Date: Wed, 21 Jan 2026 15:16:44 +0000 Subject: [PATCH 2/7] feat: Add offset and length parameters to API References: - https://outsystemsrd.atlassian.net/browse/RMET-4376 --- packages/capacitor-plugin/README.md | 12 +++++++----- packages/capacitor-plugin/src/definitions.ts | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/packages/capacitor-plugin/README.md b/packages/capacitor-plugin/README.md index 8c620cb..7524326 100644 --- a/packages/capacitor-plugin/README.md +++ b/packages/capacitor-plugin/README.md @@ -541,11 +541,13 @@ We recommend using the @capacitor/file-transfer plugin instead, in conjunction w #### ReadFileOptions -| Prop | Type | Description | Since | -| --------------- | ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- | -| **`path`** | string | The path of the file to read | 1.0.0 | -| **`directory`** | Directory | The `Directory` to read the file from | 1.0.0 | -| **`encoding`** | Encoding | The encoding to read the file in, if not provided, data is read as binary and returned as base64 encoded. Pass Encoding.UTF8 to read data as string | 1.0.0 | +| Prop | Type | Description | Default | Since | +| --------------- | ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- | ----- | +| **`path`** | string | The path of the file to read | | 1.0.0 | +| **`directory`** | Directory | The `Directory` to read the file from | | 1.0.0 | +| **`encoding`** | Encoding | The encoding to read the file in, if not provided, data is read as binary and returned as base64 encoded. Pass Encoding.UTF8 to read data as string | | 1.0.0 | +| **`offset`** | number | The offset to start reading the file from, in bytes. Can be used in conjunction with length to partially read files. | 0 | 8.1.0 | +| **`length`** | number | The length of data to read, in bytes. Any non-positive value means to read to the end of the file. Can be used in conjunction with offset to partially read files. | -1 | 8.1.0 | #### ReadFileInChunksOptions diff --git a/packages/capacitor-plugin/src/definitions.ts b/packages/capacitor-plugin/src/definitions.ts index d7834c3..1798574 100644 --- a/packages/capacitor-plugin/src/definitions.ts +++ b/packages/capacitor-plugin/src/definitions.ts @@ -229,6 +229,25 @@ export interface ReadFileOptions { * @since 1.0.0 */ encoding?: Encoding; + + /** + * The offset to start reading the file from, in bytes. + * Can be used in conjunction with length to partially read files. + * + * @since 8.1.0 + * @default 0 + */ + offset?: number; + + /** + * The length of data to read, in bytes. + * Any non-positive value means to read to the end of the file. + * Can be used in conjunction with offset to partially read files. + * + * @since 8.1.0 + * @default -1 + */ + length?: number; } export interface ReadFileInChunksOptions extends ReadFileOptions { From 739c727cd8a70fd6d6cee9f2e53db40e29a635ab Mon Sep 17 00:00:00 2001 From: OS-pedrogustavobilro Date: Wed, 21 Jan 2026 15:50:02 +0000 Subject: [PATCH 3/7] feat(android): Partial read of file Via native library version 1.1.0 --- .../capacitor-plugin/android/build.gradle | 2 +- .../plugins/filesystem/FilesystemErrors.kt | 2 ++ .../filesystem/FilesystemMethodOptions.kt | 26 +++++++++++++++++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/capacitor-plugin/android/build.gradle b/packages/capacitor-plugin/android/build.gradle index b3b3ffa..ce3f263 100644 --- a/packages/capacitor-plugin/android/build.gradle +++ b/packages/capacitor-plugin/android/build.gradle @@ -58,7 +58,7 @@ repositories { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "io.ionic.libs:ionfilesystem-android:1.0.0" + implementation "io.ionic.libs:ionfilesystem-android:1.1.0" implementation project(':capacitor-android') implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion" diff --git a/packages/capacitor-plugin/android/src/main/kotlin/com/capacitorjs/plugins/filesystem/FilesystemErrors.kt b/packages/capacitor-plugin/android/src/main/kotlin/com/capacitorjs/plugins/filesystem/FilesystemErrors.kt index 056edae..6eff078 100644 --- a/packages/capacitor-plugin/android/src/main/kotlin/com/capacitorjs/plugins/filesystem/FilesystemErrors.kt +++ b/packages/capacitor-plugin/android/src/main/kotlin/com/capacitorjs/plugins/filesystem/FilesystemErrors.kt @@ -97,5 +97,7 @@ fun Throwable.toFilesystemError(methodName: String): FilesystemErrors.ErrorInfo is IONFILEExceptions.CopyRenameFailed.NoParentDirectory -> FilesystemErrors.missingParentDirectories + is IllegalArgumentException -> FilesystemErrors.invalidInputMethod(methodName) + else -> FilesystemErrors.operationFailed(methodName, this.localizedMessage ?: "") } \ No newline at end of file diff --git a/packages/capacitor-plugin/android/src/main/kotlin/com/capacitorjs/plugins/filesystem/FilesystemMethodOptions.kt b/packages/capacitor-plugin/android/src/main/kotlin/com/capacitorjs/plugins/filesystem/FilesystemMethodOptions.kt index 6222c03..6abeb46 100644 --- a/packages/capacitor-plugin/android/src/main/kotlin/com/capacitorjs/plugins/filesystem/FilesystemMethodOptions.kt +++ b/packages/capacitor-plugin/android/src/main/kotlin/com/capacitorjs/plugins/filesystem/FilesystemMethodOptions.kt @@ -1,6 +1,7 @@ package com.capacitorjs.plugins.filesystem import com.getcapacitor.PluginCall +import io.ionic.libs.ionfilesystemlib.model.IONFILEConstants import io.ionic.libs.ionfilesystemlib.model.IONFILEEncoding import io.ionic.libs.ionfilesystemlib.model.IONFILEFolderType import io.ionic.libs.ionfilesystemlib.model.IONFILEReadInChunksOptions @@ -13,6 +14,8 @@ internal const val INPUT_APPEND = "append" private const val INPUT_PATH = "path" private const val INPUT_DIRECTORY = "directory" private const val INPUT_ENCODING = "encoding" +private const val INPUT_OFFSET = "offset" +private const val INPUT_LENGTH = "length" private const val INPUT_CHUNK_SIZE = "chunkSize" private const val INPUT_DATA = "data" private const val INPUT_RECURSIVE = "recursive" @@ -52,7 +55,15 @@ internal data class DoubleUri( internal fun PluginCall.getReadFileOptions(): ReadFileOptions? { val uri = getSingleIONFILEUri() ?: return null val encoding = IONFILEEncoding.fromEncodingName(getString(INPUT_ENCODING)) - return ReadFileOptions(uri = uri, options = IONFILEReadOptions(encoding)) + val offsetAndLength = getOffsetAndLength() + return ReadFileOptions( + uri = uri, + options = IONFILEReadOptions( + encoding, + offset = offsetAndLength.first, + length = offsetAndLength.second + ) + ) } /** @@ -62,9 +73,15 @@ internal fun PluginCall.getReadFileInChunksOptions(): ReadFileInChunksOptions? { val uri = getSingleIONFILEUri() ?: return null val encoding = IONFILEEncoding.fromEncodingName(getString(INPUT_ENCODING)) val chunkSize = getInt(INPUT_CHUNK_SIZE)?.takeIf { it > 0 } ?: return null + val offsetAndLength = getOffsetAndLength() return ReadFileInChunksOptions( uri = uri, - options = IONFILEReadInChunksOptions(encoding, chunkSize) + options = IONFILEReadInChunksOptions( + encoding, + chunkSize = chunkSize, + offset = offsetAndLength.first, + length = offsetAndLength.second + ) ) } @@ -123,6 +140,11 @@ internal fun PluginCall.getSingleIONFILEUri(): IONFILEUri.Unresolved? { return unresolvedUri(path, directoryAlias) } +private fun PluginCall.getOffsetAndLength(): Pair = Pair( + getInt(INPUT_OFFSET)?.takeIf { it >= 0 } ?: 0, + getInt(INPUT_LENGTH)?.takeIf { it > 0 } ?: IONFILEConstants.LENGTH_READ_TIL_EOF +) + private fun unresolvedUri(path: String, directoryAlias: String?) = IONFILEUri.Unresolved( parentFolder = IONFILEFolderType.fromStringAlias(directoryAlias), uriPath = path From 3f610b8996f4172be87f1916bc85cd0215e3aa4b Mon Sep 17 00:00:00 2001 From: OS-pedrogustavobilro Date: Wed, 21 Jan 2026 15:50:26 +0000 Subject: [PATCH 4/7] chore: Partial file read in example app --- .../src/js/capacitor-welcome.js | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/packages/example-app-capacitor/src/js/capacitor-welcome.js b/packages/example-app-capacitor/src/js/capacitor-welcome.js index a995afb..f2fee99 100644 --- a/packages/example-app-capacitor/src/js/capacitor-welcome.js +++ b/packages/example-app-capacitor/src/js/capacitor-welcome.js @@ -75,6 +75,8 @@ window.customElements.define(

+ +



@@ -202,7 +204,35 @@ window.customElements.define( } console.log('chunk read', JSON.stringify(chunkResult)) } - ); + ); + }); + self.shadowRoot.querySelector('#fileReadPartial').addEventListener('click', async function (e) { + let contents = await Filesystem.readFile({ + path: 'secrets/text.txt', + directory: Directory.Documents, + encoding: Encoding.UTF8, + offset: 4, + length: 5 + }); + console.log('file contents', contents.data); + }); + self.shadowRoot.querySelector('#fileReadInSmallChunksPartial').addEventListener('click', async function (e) { + await Filesystem.readFileInChunks( + { + path: 'secrets/text.txt', + directory: Directory.Documents, + encoding: Encoding.UTF8, + chunkSize: 3, // on Android the chunk size to be used will be much larger + offset: 14 + }, + (chunkResult, err) => { + if (err) { + console.log(err) + return + } + console.log('chunk read', JSON.stringify(chunkResult)) + } + ); }); self.shadowRoot.querySelector('#fileAppend').addEventListener('click', async function (e) { await Filesystem.appendFile({ From 2c4c4b8915de5d9036e849ffb86bd14c1e05da31 Mon Sep 17 00:00:00 2001 From: OS-pedrogustavobilro Date: Wed, 21 Jan 2026 16:09:20 +0000 Subject: [PATCH 5/7] feat(ios): Partial read of file --- .../capacitor-plugin/CapacitorFilesystem.podspec | 2 +- packages/capacitor-plugin/Package.swift | 2 +- .../FilesystemPlugin/FilesystemConstants.swift | 2 ++ .../FilesystemPlugin/FilesystemOperation.swift | 4 ++-- .../FilesystemOperationExecutor.swift | 16 ++++++++-------- .../FilesystemPlugin/FilesystemPlugin.swift | 8 ++++++-- .../example-app-capacitor/ios/App/Podfile.lock | 10 +++++----- 7 files changed, 25 insertions(+), 19 deletions(-) diff --git a/packages/capacitor-plugin/CapacitorFilesystem.podspec b/packages/capacitor-plugin/CapacitorFilesystem.podspec index 80b4ad2..9b1d7b6 100644 --- a/packages/capacitor-plugin/CapacitorFilesystem.podspec +++ b/packages/capacitor-plugin/CapacitorFilesystem.podspec @@ -16,6 +16,6 @@ Pod::Spec.new do |s| ] s.ios.deployment_target = '15.0' s.dependency 'Capacitor' - s.dependency 'IONFilesystemLib', spec='~> 1.0.1' + s.dependency 'IONFilesystemLib', spec='~> 1.1.0' s.swift_version = '5.1' end diff --git a/packages/capacitor-plugin/Package.swift b/packages/capacitor-plugin/Package.swift index ab092d6..99d362e 100644 --- a/packages/capacitor-plugin/Package.swift +++ b/packages/capacitor-plugin/Package.swift @@ -11,7 +11,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0"), - .package(url: "https://github.com/ionic-team/ion-ios-filesystem.git", from: "1.0.1") + .package(url: "https://github.com/ionic-team/ion-ios-filesystem.git", from: "1.1.0") ], targets: [ .target( diff --git a/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemConstants.swift b/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemConstants.swift index 909e290..9b3e3d2 100644 --- a/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemConstants.swift +++ b/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemConstants.swift @@ -26,6 +26,8 @@ struct Constants { static let directory = "directory" static let encoding = "encoding" static let chunkSize = "chunkSize" + static let offset = "offset" + static let length = "length" static let from = "from" static let path = "path" static let recursive = "recursive" diff --git a/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemOperation.swift b/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemOperation.swift index 238420f..cba3570 100644 --- a/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemOperation.swift +++ b/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemOperation.swift @@ -3,8 +3,8 @@ import IONFilesystemLib enum FilesystemOperation { // Read Operations - case readFile(url: URL, encoding: IONFILEEncoding) - case readFileInChunks(url: URL, encoding: IONFILEEncoding, chunkSize: Int) + case readFile(url: URL, encoding: IONFILEEncoding, offset: Int, length: Int) + case readFileInChunks(url: URL, encoding: IONFILEEncoding, chunkSize: Int, offset: Int, length: Int) case readdir(url: URL) case stat(url: URL) case getUri(url: URL) diff --git a/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemOperationExecutor.swift b/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemOperationExecutor.swift index afcf637..12f739c 100644 --- a/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemOperationExecutor.swift +++ b/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemOperationExecutor.swift @@ -16,11 +16,11 @@ class FilesystemOperationExecutor { var resultData: PluginCallResultData? switch operation { - case .readFile(let url, let encoding): - let data = try service.readEntireFile(atURL: url, withEncoding: encoding).textValue + case .readFile(let url, let encoding, let offset, let length): + let data = try service.readEntireFile(atURL: url, withEncoding: encoding, andOffset: offset, andLength: length).textValue resultData = [Constants.ResultDataKey.data: data] - case .readFileInChunks(let url, let encoding, let chunkSize): - try processFileInChunks(at: url, withEncoding: encoding, chunkSize: chunkSize, for: operation, call) + case .readFileInChunks(let url, let encoding, let chunkSize, let offset, let length): + try processFileInChunks(at: url, withEncoding: encoding, chunkSize: chunkSize, offset: offset, length: length, for: operation, call) return case .write(let url, let encodingMapper, let recursive): try service.saveFile(atURL: url, withEncodingAndData: encodingMapper, includeIntermediateDirectories: recursive) @@ -56,9 +56,9 @@ class FilesystemOperationExecutor { } private extension FilesystemOperationExecutor { - func processFileInChunks(at url: URL, withEncoding encoding: IONFILEEncoding, chunkSize: Int, for operation: FilesystemOperation, _ call: CAPPluginCall) throws { + func processFileInChunks(at url: URL, withEncoding encoding: IONFILEEncoding, chunkSize: Int, offset: Int, length:Int, for operation: FilesystemOperation, _ call: CAPPluginCall) throws { let chunkSizeToUse = chunkSizeToUse(basedOn: chunkSize, and: encoding) - try service.readFileInChunks(atURL: url, withEncoding: encoding, andChunkSize: chunkSizeToUse) + try service.readFileInChunks(atURL: url, withEncoding: encoding, andChunkSize: chunkSizeToUse, andOffset: offset, andLength: length) .sink(receiveCompletion: { completion in switch completion { case .finished: @@ -82,8 +82,8 @@ private extension FilesystemOperationExecutor { var path = "" var method: IONFileMethod = IONFileMethod.getUri switch operation { - case .readFile(let url, _): path = url.absoluteString; method = .readFile - case .readFileInChunks(let url, _, _): path = url.absoluteString; method = .readFileInChunks + case .readFile(let url, _, _, _): path = url.absoluteString; method = .readFile + case .readFileInChunks(let url, _, _, _, _): path = url.absoluteString; method = .readFileInChunks case .write(let url, _, _): path = url.absoluteString; method = .writeFile case .append(let url, _, _): path = url.absoluteString; method = .appendFile case .delete(let url): path = url.absoluteString; method = .deleteFile diff --git a/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemPlugin.swift b/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemPlugin.swift index 763601a..c743510 100644 --- a/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemPlugin.swift +++ b/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemPlugin.swift @@ -59,8 +59,10 @@ private extension FilesystemPlugin { */ @objc func readFile(_ call: CAPPluginCall) { let encoding = call.getEncoding(Constants.MethodParameter.encoding) + let offset = call.getInt(Constants.MethodParameter.offset) ?? 0 + let length = call.getInt(Constants.MethodParameter.length) ?? -1 performSinglePathOperation(call) { - .readFile(url: $0, encoding: encoding) + .readFile(url: $0, encoding: encoding, offset: offset, length: length) } } @@ -69,8 +71,10 @@ private extension FilesystemPlugin { guard let chunkSize = call.getInt(Constants.MethodParameter.chunkSize) else { return call.handleError(.invalidInput(method: call.getIONFileMethod())) } + let offset = call.getInt(Constants.MethodParameter.offset) ?? 0 + let length = call.getInt(Constants.MethodParameter.length) ?? -1 performSinglePathOperation(call) { - .readFileInChunks(url: $0, encoding: encoding, chunkSize: chunkSize) + .readFileInChunks(url: $0, encoding: encoding, chunkSize: chunkSize, offset: offset, length: length) } } diff --git a/packages/example-app-capacitor/ios/App/Podfile.lock b/packages/example-app-capacitor/ios/App/Podfile.lock index 344b4b1..8973ac1 100644 --- a/packages/example-app-capacitor/ios/App/Podfile.lock +++ b/packages/example-app-capacitor/ios/App/Podfile.lock @@ -6,10 +6,10 @@ PODS: - CapacitorCordova (8.0.1) - CapacitorFilesystem (8.0.0): - Capacitor - - IONFilesystemLib (~> 1.0.1) + - IONFilesystemLib (~> 1.1.0) - CapacitorSplashScreen (8.0.0): - Capacitor - - IONFilesystemLib (1.0.1) + - IONFilesystemLib (1.1.0) DEPENDENCIES: - "Capacitor (from `../../node_modules/@capacitor/ios`)" @@ -38,10 +38,10 @@ SPEC CHECKSUMS: Capacitor: ff35b0f66370b84aa238251b35b91886a3207c16 CapacitorCamera: 592acb7ab9fb748e2d8571eb03af30ec4e1ace12 CapacitorCordova: 0d65b9bb74e995dcecb9463f34f1af2aba6f955c - CapacitorFilesystem: bb9d1efbf934a3c161425e2415b9baf539cdfac3 + CapacitorFilesystem: c650a2b46e2bbeb4709aef2bcf0a44597e20158c CapacitorSplashScreen: 422880d7117605c30699eb4b21644b62db42e86c - IONFilesystemLib: 89258b8e3e85465da93127d25d7ce37f977e8a6f + IONFilesystemLib: 50b9a0f3052a9b40b9bedb43f328a8fe222f9f87 PODFILE CHECKSUM: f9801285586b6499bc9e372b1475a3f09f847217 -COCOAPODS: 1.14.3 +COCOAPODS: 1.16.2 From fe8ee0fa3e3ea8ab12b372c77df89c22eb79e047 Mon Sep 17 00:00:00 2001 From: OS-pedrogustavobilro Date: Wed, 21 Jan 2026 16:15:08 +0000 Subject: [PATCH 6/7] docs: Make length and offset explicitly native only --- packages/capacitor-plugin/README.md | 14 +++++++------- packages/capacitor-plugin/src/definitions.ts | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/capacitor-plugin/README.md b/packages/capacitor-plugin/README.md index 7524326..9a0c910 100644 --- a/packages/capacitor-plugin/README.md +++ b/packages/capacitor-plugin/README.md @@ -541,13 +541,13 @@ We recommend using the @capacitor/file-transfer plugin instead, in conjunction w #### ReadFileOptions -| Prop | Type | Description | Default | Since | -| --------------- | ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- | ----- | -| **`path`** | string | The path of the file to read | | 1.0.0 | -| **`directory`** | Directory | The `Directory` to read the file from | | 1.0.0 | -| **`encoding`** | Encoding | The encoding to read the file in, if not provided, data is read as binary and returned as base64 encoded. Pass Encoding.UTF8 to read data as string | | 1.0.0 | -| **`offset`** | number | The offset to start reading the file from, in bytes. Can be used in conjunction with length to partially read files. | 0 | 8.1.0 | -| **`length`** | number | The length of data to read, in bytes. Any non-positive value means to read to the end of the file. Can be used in conjunction with offset to partially read files. | -1 | 8.1.0 | +| Prop | Type | Description | Default | Since | +| --------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------- | ----- | +| **`path`** | string | The path of the file to read | | 1.0.0 | +| **`directory`** | Directory | The `Directory` to read the file from | | 1.0.0 | +| **`encoding`** | Encoding | The encoding to read the file in, if not provided, data is read as binary and returned as base64 encoded. Pass Encoding.UTF8 to read data as string | | 1.0.0 | +| **`offset`** | number | The offset to start reading the file from, in bytes. Native only (not available in web). Can be used in conjunction with length to partially read files. | 0 | 8.1.0 | +| **`length`** | number | The length of data to read, in bytes. Any non-positive value means to read to the end of the file. Native only (not available in web). Can be used in conjunction with offset to partially read files. | -1 | 8.1.0 | #### ReadFileInChunksOptions diff --git a/packages/capacitor-plugin/src/definitions.ts b/packages/capacitor-plugin/src/definitions.ts index 1798574..6eb2576 100644 --- a/packages/capacitor-plugin/src/definitions.ts +++ b/packages/capacitor-plugin/src/definitions.ts @@ -232,6 +232,7 @@ export interface ReadFileOptions { /** * The offset to start reading the file from, in bytes. + * Native only (not available in web). * Can be used in conjunction with length to partially read files. * * @since 8.1.0 @@ -242,6 +243,7 @@ export interface ReadFileOptions { /** * The length of data to read, in bytes. * Any non-positive value means to read to the end of the file. + * Native only (not available in web). * Can be used in conjunction with offset to partially read files. * * @since 8.1.0 From 64ce2e1b14f62e51cf62950a291899610c802418 Mon Sep 17 00:00:00 2001 From: OS-pedrogustavobilro Date: Wed, 21 Jan 2026 16:22:10 +0000 Subject: [PATCH 7/7] chore: fix lint issues --- .../FilesystemPlugin/FilesystemOperationExecutor.swift | 2 +- packages/capacitor-plugin/src/definitions.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemOperationExecutor.swift b/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemOperationExecutor.swift index 12f739c..c5eea30 100644 --- a/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemOperationExecutor.swift +++ b/packages/capacitor-plugin/ios/Sources/FilesystemPlugin/FilesystemOperationExecutor.swift @@ -56,7 +56,7 @@ class FilesystemOperationExecutor { } private extension FilesystemOperationExecutor { - func processFileInChunks(at url: URL, withEncoding encoding: IONFILEEncoding, chunkSize: Int, offset: Int, length:Int, for operation: FilesystemOperation, _ call: CAPPluginCall) throws { + func processFileInChunks(at url: URL, withEncoding encoding: IONFILEEncoding, chunkSize: Int, offset: Int, length: Int, for operation: FilesystemOperation, _ call: CAPPluginCall) throws { let chunkSizeToUse = chunkSizeToUse(basedOn: chunkSize, and: encoding) try service.readFileInChunks(atURL: url, withEncoding: encoding, andChunkSize: chunkSizeToUse, andOffset: offset, andLength: length) .sink(receiveCompletion: { completion in diff --git a/packages/capacitor-plugin/src/definitions.ts b/packages/capacitor-plugin/src/definitions.ts index 6eb2576..72e4141 100644 --- a/packages/capacitor-plugin/src/definitions.ts +++ b/packages/capacitor-plugin/src/definitions.ts @@ -229,12 +229,12 @@ export interface ReadFileOptions { * @since 1.0.0 */ encoding?: Encoding; - + /** * The offset to start reading the file from, in bytes. * Native only (not available in web). * Can be used in conjunction with length to partially read files. - * + * * @since 8.1.0 * @default 0 */ @@ -245,7 +245,7 @@ export interface ReadFileOptions { * Any non-positive value means to read to the end of the file. * Native only (not available in web). * Can be used in conjunction with offset to partially read files. - * + * * @since 8.1.0 * @default -1 */