upload abstract method
Uploads data to the server.
This method uploads data (typically files) to the server. Progress can be
tracked using the optional onProgress callback.
Parameters:
request: The request configuration for the upload, including the data to uploadonProgress: Optional callback to track upload progress
Returns a Future that completes with an AdapterResponse when the upload is complete.
Throws AdapterException if the upload fails.
Example:
final request = AdapterRequest(
baseUrl: 'https://api.example.com',
path: '/upload',
method: HttpMethod.post,
bodyParams: {'file': File('/path/to/file.jpg')},
);
await adapter.upload(
request,
onProgress: (count, total) {
print('Uploaded: ${(count / total * 100).toStringAsFixed(1)}%');
},
);
Implementation
Future<AdapterResponse> upload(
AdapterRequest request, {
ProgressCallback? onProgress,
});