stream-chat-android icon indicating copy to clipboard operation
stream-chat-android copied to clipboard

Support set custom extraData for Attachment from FileUploader

Open donlan opened this issue 2 years ago • 4 comments

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))
    }

donlan avatar Feb 22 '23 09:02 donlan

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.

filbabic avatar Feb 22 '23 10:02 filbabic

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 avatar Feb 22 '23 11:02 donlan

@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.

filbabic avatar Feb 23 '23 08:02 filbabic

@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!

donlan avatar Feb 23 '23 08:02 donlan

Hello @donlan We already added extraData to UploadedFile class. It was implemented on #5230 and it is already available on our last release.

JcMinarro avatar Jul 02 '24 09:07 JcMinarro