# Senbird throws an exception error when trying to send file message

**URL:** <https://community.sendbird.com/t/senbird-throws-an-exception-error-when-trying-to-send-file-message/7422>\
**Category:** Miscellaneous\
**Created:** [May 25, 2023, 4:58pm UTC](https://community.sendbird.com/t/senbird-throws-an-exception-error-when-trying-to-send-file-message/7422 "2023-05-25T16:58:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Namrata\_Jain](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/namrata_jain/32/3826_2.png) [@Namrata\_Jain](https://community.sendbird.com/u/Namrata_Jain)\
**Post date:** [May 25, 2023, 4:58pm UTC](https://community.sendbird.com/t/senbird-throws-an-exception-error-when-trying-to-send-file-message/7422/1 "2023-05-25T16:58:44Z")

</div>

I want to send a file message and for doing so i am using [Send a message | Chat Platform API | Sendbird Docs](https://sendbird.com/docs/chat/v3/platform-api/message/messaging-basics/send-a-message) JS chat SDK.

The params:

```auto
const params = {
        fileUrl: MSG?.uri,
        fileName: MSG?.fileName,
        fileSize: MSG?.fileSize,
        thumbnailSizes: [
          { maxWidth: 100, maxHeight: 100 },
          { maxWidth: 200, maxHeight: 200 },
        ],
        mimeType: MSG?.type,
        customType: "",
        mentionType: "users",
        mentionedUserIds: [],
      };

```

```auto
ticket.channel.sendFileMessage(params, (message, error) => {
        if (error) {
          console.log("e", error);
        }
        console.log("message", message);
      });

```

The selected file object is:

 ![Screenshot 2023-05-25 at 10.25.02 PM](https://us1.discourse-cdn.com/flex020/uploads/sendbird/original/2X/b/b49a341e73557469035b4fa99c317f725bf19cfa.png)

Here’s the error that i get:

 ![Screenshot 2023-05-25 at 10.25.38 PM](https://us1.discourse-cdn.com/flex020/uploads/sendbird/original/2X/3/35f01c658314a69b0c396fb1c61c880f1c42115c.png)

I aslo tried to send a splash image url to verify if this error is due to file uri, but it threw the same error for the latter.

What am i missing or doing the wrong way here?

---

<div class="post-metadata">

**Author:** ![Airen\_Kang](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/airen_kang/32/1831_2.png) [@Airen\_Kang](https://community.sendbird.com/u/Airen_Kang)\
**Post date:** [June 1, 2023, 4:33am UTC](https://community.sendbird.com/t/senbird-throws-an-exception-error-when-trying-to-send-file-message/7422/2 "2023-06-01T04:33:09Z")

</div>

Hi @Namrata_Jain, what version of Chat SDK are you using?

```ts
import {} from 'sendbird'; // v3
import {} from '@sendbird/chat'; // v4

```

FYI, If you are using `sendbird-desk` SDK, the Chat SDK version is v3.

---

<div class="post-metadata">

**Author:** ![Namrata\_Jain](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/namrata_jain/32/3826_2.png) [@Namrata\_Jain](https://community.sendbird.com/u/Namrata_Jain)\
**Post date:** [June 1, 2023, 5:01am UTC](https://community.sendbird.com/t/senbird-throws-an-exception-error-when-trying-to-send-file-message/7422/3 "2023-06-01T05:01:48Z")

</div>

we are using ticket instance passed from ticketChannel,

```auto
const sendCustomerInput = (
    MSG,
    ticket,
    setCustomerInputText,
    isFileMessage
  ) => {
    if (isFileMessage) {
      ticket.channel.sendFileMessage(
        {
          file: {
            size: MSG?.fileSize,
            uri: MSG?.uri,
            type: MSG?.type,
            name: MSG?.fileName,
          },
        },
        (message, error) => {
          if (error) {
            console.log("e", error);
          }
          console.log("message", message);
        }
      );
    }

```

we are sending the ticket instance from other component to this above function, and trying to send the file message using  
`ticket.channel.sendFileMessage()`

And we are following this as per the documentation.

> **[Send a message | Chat JavaScript SDK | Sendbird Docs](https://sendbird.com/docs/chat/v4/javascript/message/sending-a-message/send-a-message)**
>
> Guides for quick and easy integration of Sendbird Chat, Calls and Desk for iOS, Android, JavaScript, Unity, .NET and Platform API.

We could not understand the above answer which is related to the version of sendbird chat, we are unable to understand in what context is it related to the question asked by us.

---

<div class="post-metadata">

**Author:** ![Airen\_Kang](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/airen_kang/32/1831_2.png) [@Airen\_Kang](https://community.sendbird.com/u/Airen_Kang)\
**Post date:** [June 1, 2023, 5:26am UTC](https://community.sendbird.com/t/senbird-throws-an-exception-error-when-trying-to-send-file-message/7422/4 "2023-06-01T05:26:02Z")

</div>

Sendbird chat SDK has two versions: v3 and v4.  
The implementation of sending file messages varies depending on the SDK version being used. Therefore, it isn’t easy to provide an accurate answer based solely on the current question.

The format of the code and logs you provided does not seem to match the version mentioned in the document you followed, so knowing the SDK version you are using will help me provide the correct response.

---

<div class="post-metadata">

**Author:** ![Namrata\_Jain](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/namrata_jain/32/3826_2.png) [@Namrata\_Jain](https://community.sendbird.com/u/Namrata_Jain)\
**Post date:** [June 1, 2023, 6:36am UTC](https://community.sendbird.com/t/senbird-throws-an-exception-error-when-trying-to-send-file-message/7422/5 "2023-06-01T06:36:56Z")

</div>

Our chat SDK version is v4,

```auto
 "@sendbird/chat": "^4.7.2",
 "sendbird-desk": "^1.0.23"

```

---

<div class="post-metadata">

**Author:** ![Airen\_Kang](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/airen_kang/32/1831_2.png) [@Airen\_Kang](https://community.sendbird.com/u/Airen_Kang)\
**Post date:** [June 1, 2023, 7:23am UTC](https://community.sendbird.com/t/senbird-throws-an-exception-error-when-trying-to-send-file-message/7422/6 "2023-06-01T07:23:40Z")

</div>

As mentioned above, the v3 chat SDK is used within sendbird-desk.  
Please try the following:

```js
import SendBird from 'sendbird';
const sb = SendBird.getInstance();
const params = new sb.FileMessageParams();
params.file = {
    size: MSG?.fileSize,
    uri: MSG?.uri,
    type: MSG?.type,
    name: MSG?.fileName,
};

ticket.channel.sendFileMessage(params, (message, error) => {
    if (error) {
        console.log("e", error);
    }
    console.log("message", message);
});

```

> <https://github.com/sendbird/sendbird-javascript-samples/blob/master/react-native/react-native-hook/Sendbird/src/page/chat.js#L238-L255>

---

<div class="post-metadata">

**Author:** ![Namrata\_Jain](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/namrata_jain/32/3826_2.png) [@Namrata\_Jain](https://community.sendbird.com/u/Namrata_Jain)\
**Post date:** [June 1, 2023, 8:23am UTC](https://community.sendbird.com/t/senbird-throws-an-exception-error-when-trying-to-send-file-message/7422/7 "2023-06-01T08:23:43Z")

</div>

Thank you @Airen_Kang , this worked for us, it’s working as expected now.

---

<div class="post-metadata">

**Author:** ![Namrata\_Jain](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/namrata_jain/32/3826_2.png) [@Namrata\_Jain](https://community.sendbird.com/u/Namrata_Jain)\
**Post date:** [June 23, 2023, 9:54am UTC](https://community.sendbird.com/t/senbird-throws-an-exception-error-when-trying-to-send-file-message/7422/8 "2023-06-23T09:54:50Z")

</div>

Hey @Airen_Kang we also want to generate thumnails for our file messages, we tried to follow your documentation but failed to achieve it.

The documentation we followed to achieve it is here: [Generate thumbnails of a file message | Chat JavaScript SDK | Sendbird Docs](https://sendbird.com/docs/chat/v4/javascript/message/managing-a-message/generate-thumbnails-of-a-file-message#1-generate-thumbnails-of-a-file-message)

the updated params we are sending is:

```auto
const params = new sendbirdInstance.FileMessageParams();
        params.file = {
          size: MSG?.fileSize,
          uri: MSG?.uri,
          type: MSG?.type,
          name: MSG?.fileName,
          thumbnailSizes: [
            { maxWidth: 100, maxHeight: 100 },
            { maxWidth: 200, maxHeight: 200 },
          ],
        };

```

but in our response we get no thumbnails.

 ![Screenshot 2023-06-23 at 3.24.23 PM](https://us1.discourse-cdn.com/flex020/uploads/sendbird/original/2X/4/49f206f29b73d6aebef733c9aaf1b2c73443272d.png)

what are we missing here?
