From 071fc11704cbcf36f16ebd0000968f44010fced7 Mon Sep 17 00:00:00 2001 From: Ritesh Khadse Date: Tue, 16 Jan 2024 14:42:41 +0530 Subject: [PATCH] [postFile] add query parameters for postfile method Signed-off-by: Ritesh Khadse --- lib/src/api_service_impl.dart | 9 +++++++++ lib/src/base/api_service.dart | 12 ++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/src/api_service_impl.dart b/lib/src/api_service_impl.dart index f814a04..d51cbb1 100644 --- a/lib/src/api_service_impl.dart +++ b/lib/src/api_service_impl.dart @@ -108,8 +108,17 @@ class ApiServiceImpl implements ApiService { File? file, ProgressCallback? onSendProgress, ApiOptions? options, + Map? queryParameters, }) async { endpoint = endpoint != null ? "$baseUrl$endpoint" : getFileUploadUrl(); + if (queryParameters != null) { + var queryUrl = ""; + for (final parameter in queryParameters.entries) { + queryUrl = + "${queryUrl.isEmpty ? '?' : '&'}${parameter.key}=${parameter.value}"; + } + endpoint = "$endpoint$queryUrl"; + } keyName = keyName ?? 'asset'; if (file == null) { throw const MyException("Attached file is null"); diff --git a/lib/src/base/api_service.dart b/lib/src/base/api_service.dart index 4e5e147..8a2b3e0 100644 --- a/lib/src/base/api_service.dart +++ b/lib/src/base/api_service.dart @@ -30,12 +30,12 @@ abstract class ApiService { ApiOptions? options, }); - Future> postFile({ - String? endpoint, - String? keyName, - File? file, - ProgressCallback? onSendProgress, - }); + Future> postFile( + {String? endpoint, + String? keyName, + File? file, + ProgressCallback? onSendProgress, + Map? queryParameters}); void setBaseUrl(String baseUrl);