upload abstract method

Future<AdapterResponse> upload(
  1. AdapterRequest request, {
  2. ProgressCallback? onProgress,
})

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 upload
  • onProgress: 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,
});