readInPlaceBytes static method
Read a file in place as bytes from the iCloud container using coordinated access.
relativePath is the path within the iCloud container.
Trailing slashes are rejected here because reads are file-centric and coordinated through UIDocument/NSDocument.
Coordinated access loads the full contents into memory. Use for small files.
idleTimeouts configures the idle watchdog for downloads (defaults to
60s, 90s, 180s).
retryBackoff configures the retry delay between attempts (exponential
backoff by default).
Returns the file contents as bytes.
Throws on file-not-found and other failures.
Implementation
static Future<Uint8List?> readInPlaceBytes({
required String containerId,
required String relativePath,
List<Duration>? idleTimeouts,
List<Duration>? retryBackoff,
}) async {
if (relativePath.endsWith('/')) {
throw InvalidArgumentException('invalid relativePath: $relativePath');
}
if (relativePath.trim().isEmpty) {
throw InvalidArgumentException('invalid relativePath: $relativePath');
}
if (!_validateRelativePath(relativePath)) {
throw InvalidArgumentException('invalid relativePath: $relativePath');
}
return ICloudStoragePlatform.instance.readInPlaceBytes(
containerId: containerId,
relativePath: relativePath,
idleTimeouts: idleTimeouts,
retryBackoff: retryBackoff,
);
}