uploadFile method
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',
);
}