uploadFile method
Upload a file
Implementation
Future<FileUploadResponse> uploadFile(
String filePath, {
String fieldName = 'file',
Map<String, dynamic>? metadata,
void Function(double progress)? onProgress,
}) async {
final response = await _apiClient.uploadFile<Map<String, dynamic>>(
'/files/upload',
filePath,
fieldName: fieldName,
additionalData: metadata,
onProgress: (sent, total) {
if (onProgress != null && total > 0) {
onProgress(sent / total);
}
},
);
return FileUploadResponse.fromJson(response);
}