Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[postFile] add query parameters for postfile method #36

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading