feat(llc): add support for AttachmentFileUploaderProvider. (#1246)
* feat(llc): add support for `AttachmentFileUploaderProvider`. Signed-off-by: xsahil03x <[email protected]> * chore(llc): update CHANGELOG.md Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
@@ -3,6 +3,11 @@ import 'package:stream_chat/src/core/api/responses.dart';
|
||||
import 'package:stream_chat/src/core/http/stream_http_client.dart';
|
||||
import 'package:stream_chat/src/core/models/attachment_file.dart';
|
||||
|
||||
/// Signature for a function which provides instance of [AttachmentFileUploader]
|
||||
typedef AttachmentFileUploaderProvider = AttachmentFileUploader Function(
|
||||
StreamHttpClient httpClient,
|
||||
);
|
||||
|
||||
/// Class responsible for uploading images and files to a given channel
|
||||
abstract class AttachmentFileUploader {
|
||||
/// Uploads a [image] to the given channel.
|
||||
|
||||
@@ -22,9 +22,10 @@ class StreamChatApi {
|
||||
StreamHttpClientOptions? options,
|
||||
TokenManager? tokenManager,
|
||||
ConnectionIdManager? connectionIdManager,
|
||||
AttachmentFileUploader? attachmentFileUploader,
|
||||
AttachmentFileUploaderProvider? attachmentFileUploaderProvider,
|
||||
Logger? logger,
|
||||
}) : _fileUploader = attachmentFileUploader,
|
||||
}) : _fileUploaderProvider =
|
||||
attachmentFileUploaderProvider ?? StreamAttachmentFileUploader.new,
|
||||
_client = client ??
|
||||
StreamHttpClient(
|
||||
apiKey,
|
||||
@@ -35,6 +36,7 @@ class StreamChatApi {
|
||||
);
|
||||
|
||||
final StreamHttpClient _client;
|
||||
final AttachmentFileUploaderProvider _fileUploaderProvider;
|
||||
|
||||
UserApi? _user;
|
||||
|
||||
@@ -75,5 +77,5 @@ class StreamChatApi {
|
||||
|
||||
/// Class responsible for uploading images and files to a given channel
|
||||
AttachmentFileUploader get fileUploader =>
|
||||
_fileUploader ??= StreamAttachmentFileUploader(_client);
|
||||
_fileUploader ??= _fileUploaderProvider.call(_client);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user