uploadFile method
Uploads a file from a localPath
to a remotePath
in the cloud.
Implementation
@override
Future<String> uploadFile({
required String localPath,
required String remotePath,
Map<String, dynamic>? metadata,
}) async {
try {
await _icloudSync.upload(
containerId: _containerId,
filePath: localPath,
destinationRelativePath: _sanitizePath(remotePath),
);
return remotePath;
} on PlatformException catch (e) {
// ADD THIS CHECK: for "No Connection" (NSURLErrorDomain Code -1009)
if (e.code == '-1009' ||
e.toString().contains('NSURLErrorDomain Code=-1009')) {
throw NoConnectionException(
'Failed to upload to iCloud. Please check your internet connection.');
}
rethrow;
}
}