Skip to content

Commit

Permalink
[postFile] add query parameters for postfile method
Browse files Browse the repository at this point in the history
Signed-off-by: Ritesh Khadse <[email protected]>
  • Loading branch information
Ritsz123 authored and TusharFA committed Jan 16, 2024
1 parent b80a47b commit 071fc11
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
9 changes: 9 additions & 0 deletions lib/src/api_service_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,17 @@ class ApiServiceImpl implements ApiService {
File? file,
ProgressCallback? onSendProgress,
ApiOptions? options,
Map<String, dynamic>? 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");
Expand Down
12 changes: 6 additions & 6 deletions lib/src/base/api_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ abstract class ApiService {
ApiOptions? options,
});

Future<Response<T>> postFile<T>({
String? endpoint,
String? keyName,
File? file,
ProgressCallback? onSendProgress,
});
Future<Response<T>> postFile<T>(
{String? endpoint,
String? keyName,
File? file,
ProgressCallback? onSendProgress,
Map<String, dynamic>? queryParameters});

void setBaseUrl(String baseUrl);

Expand Down

0 comments on commit 071fc11

Please sign in to comment.