upload static method
Future<void>
upload({
- required String containerId,
- required String filePath,
- String? destinationRelativePath,
- StreamHandler<
double> ? onProgress,
Initiate to upload a file to iCloud
containerId is the iCloud Container Id.
filePath is the full path of the local file
destinationRelativePath is the relative path of the file you want to
store in iCloud. If not specified, the name of the local file name is
used.
onProgress is an optional callback to track the progress of the
upload. It takes a Stream
The returned future completes without waiting for the file to be uploaded to iCloud
Implementation
static Future<void> upload({
required String containerId,
required String filePath,
String? destinationRelativePath,
StreamHandler<double>? onProgress,
}) async {
if (filePath.trim().isEmpty) {
throw InvalidArgumentException('invalid filePath');
}
final destination = destinationRelativePath ?? filePath.split('/').last;
if (!_validateRelativePath(destination)) {
throw InvalidArgumentException('invalid destination relative path');
}
await ICloudStoragePlatform.instance.upload(
containerId: containerId,
filePath: filePath,
destinationRelativePath: destination,
onProgress: onProgress,
);
}