stream-chat-android
stream-chat-android copied to clipboard
Support set custom extraData for Attachment from FileUploader
e.g.
override fun sendImage(
channelType: String,
channelId: String,
userId: String,
file: File,
callback: ProgressCallback,
): Result<UploadedImage> {
// uploading ...
// val extra = some data from upload api
// UploadedImage.extraData would be set to Attachment.extraData
return UploadedImage(file = it.file, extraData = mapOf(extra))
}
Hey @donlan !
Any reason why you're opting in to use this API rather than a ChatClient.sendMessage or MessageComposerViewModel.sendMessage() or even MessageInputViewModel.sendMessage()?
All of these approaches and API entries allow you to pass in a message, with fully custom extraData on the Message, as well as Attachments that you need that also have the option to contain extraData.
Yeah,I know how to add extraData to Attachement with this way:
channel.sendMessage(
Message(cid = channel.cid,
text = "bar",
attachments = mutableListOf(
Attachment(
type = "foo",
extraData = mutableMapOf(
"key" to "value",
)
)
))
But if i implement a custom FileUploader to upload file to our Server.I have no way to put the other extra datas to Attachment, because Stream FileUploader.sendFile api only return Result<UploadedFile>。And some extra datas only return from our upload server after file upload success. I thing this is easy to you to pass the extra datas to Attachment.
@donlan Fair enough!
I'll look into this with the team to see if the extraData can be exposed here and accepted on the BE side.
@donlan Fair enough!
I'll look into this with the team to see if the extraData can be exposed here and accepted on the BE side.
Thanks!
Hello @donlan
We already added extraData to UploadedFile class.
It was implemented on #5230 and it is already available on our last release.