uploadFile method

  1. @override
Future<String> uploadFile({
  1. required String localPath,
  2. required String remotePath,
  3. Map<String, dynamic>? metadata,
})
override

Uploads a file from a localPath to a remotePath in OneDrive.

Implementation

@override
Future<String> uploadFile({
  required String localPath,
  required String remotePath,
  Map<String, dynamic>? metadata,
}) {
  return _executeRequest(
    () async {
      final file = File(localPath);
      final bytes = await file.readAsBytes();
      // The `isAppFolder` flag directs the upload to the special "App Root" folder.
      final response = await client.push(bytes, remotePath,
          isAppFolder:
              MultiCloudStorage.cloudAccess == CloudAccessType.appStorage);
      if (response.message?.contains('SocketException') ?? false) {
        throw NoConnectionException(response.message ?? response.toString());
      }
      return remotePath; // Return remote path on success.
    },
    operation: 'uploadFile to $remotePath',
  );
}