sendFile method

  1. @override
Future<SendFileResponse> sendFile(
  1. AttachmentFile file,
  2. String channelId,
  3. String channelType, {
  4. ProgressCallback? onSendProgress,
  5. CancelToken? cancelToken,
  6. Map<String, Object?>? extraData,
})
override

Uploads a file to the given channel. Returns SendFileResponse once sent successfully.

Optionally, access upload progress using onSendProgress and cancel the request using cancelToken

Implementation

@override
Future<SendFileResponse> sendFile(
  AttachmentFile file,
  String channelId,
  String channelType, {
  ProgressCallback? onSendProgress,
  CancelToken? cancelToken,
  Map<String, Object?>? extraData,
}) async {
  final multiPartFile = await file.toMultipartFile();
  final response = await _client.postFile(
    '/channels/$channelType/$channelId/file',
    multiPartFile,
    onSendProgress: onSendProgress,
    cancelToken: cancelToken,
  );
  return SendFileResponse.fromJson(response.data);
}