uploadFile method
Uploads a file to the cloud storage.
Implementation
@override
Future<String> uploadFile(
{required String localPath,
required String remotePath,
Map<String, dynamic>? metadata}) async {
_checkAuth();
final file = File(localPath);
final fileStream = file.openRead();
final fileSize = await file.length();
final response = await _dio.post(
'https://content.dropboxapi.com/2/files/upload',
data: fileStream,
options: Options(
headers: {
'Dropbox-API-Arg': jsonEncode({
'path': _normalizePath(remotePath),
'mode': 'add', // or 'overwrite'
'autorename': true,
}),
'Content-Type': 'application/octet-stream',
'Content-Length': fileSize,
},
),
);
return response.data['id'];
}