uploadMultipleFiles method
Implementation
Future<List<String>> uploadMultipleFiles({
required String url,
required List<String> filePaths,
String fileKey = 'files',
Map<String, dynamic>? formData,
Map<String, dynamic>? headers,
bool useWithoutToken = false,
CancelToken? cancelToken,
void Function(int, int)? onSendProgress,
}) async {
try {
final formDataMap = FormData.fromMap({
...?formData,
fileKey: filePaths.map((path) => MultipartFile.fromFileSync(path)).toList(),
});
final response = await _dio.post(
url,
data: formDataMap,
options: Options(
headers: headers,
extra: {'useWithoutToken': useWithoutToken},
),
cancelToken: cancelToken,
onSendProgress: onSendProgress,
);
return List<String>.from(response.data['paths'] ?? response.data['urls']);
} on DioException catch (e) {
throw _handleDioError(e);
}
}