Cannot send filemessage on android

[Problem/Question]
// Detailed description of issue.
Cannot send filemessage from android. it works on ios.
Tried the javascript sdk and the uikit same problem. works on ios and not on android.
the error message says network error from the sdk. on uikit it just shows failure


// If problem, please fill out the below. If question, please delete.
[UIKit Version]
// What version of the SDK are you using?
2.5.0
@sendbird/chat: 4.8.5 and 4.9.0 both tested

[Reproduction Steps]
// Please provide reproduction steps and, if possible, code snippets.
reproduced on expo example app. sendbird/sendbird-uikit-sample-react-native-expo: [Sample] React-Native UIKit for Expo (github.com)

[Frequency]
// How frequently is this issue occurring?
everytime

[Current impact]
// How is this currently impacting your implementation?
Blocker

Hello @Dinesh_Devkota,

Welcome to the Sendbird Community!

To further investigate the issue can you please share the following,

  1. Additional logging details pertaining to the file upload error
  2. Is this happening to a specific android device or on simulator?

Regards,
Thanraj P

Sorry, i didnt check this after about 5 days. we implemented the feature by uploading to our own s3.
Happened on all android device we tested. even after build same problem. we tried using vpns and changed the dns of the devices. the problem still persists.
THere was not much information in logging. just that it failed to upload file.
Weirdly it worked on ios and web. so it might be something to do with react native implementation or in the js sdk itself

@Dinesh_Devkota and @Thanraj

I stumbled across the same issue today.

The “network error” error can be thrown when an invalid mimeType is supplied to the type property when uploading a file.

In my case I am using expo-image-picker, which seems to return a valid mimeType for the file on iOS but not on android. On android it just returns jpeg. If this value is passed when uploading a file you will get this error.

So if anyone else is experiencing this issue, I would suggest enabling the debug log level for the Sendbird SDK and looking at the payload supplied when uploading a file.

Here is an example of the failing payload

{
  "params": {
      "file": {
          "uri": "file:///data/user/0/[REDACTED]/cache/ImagePicker/0ac90a8f-5382-4d39-a06d-b8df981acebf.jpeg",
          "name": "New File",
          "type": "jpeg"
      },
      "channel_url": "sendbird_group_channel_269151523_f34ee485e2428sdgdfgdfg"
  },
  "requireAuth": true,
  "headers": {},
  "requestId": "rq-71520610-d9ca-4965-aa54-97a4fda35ae4",
  "method": "POST",
  "path": "/v3/storage/file"
}

and here is what a correct payload should look like.

{
    "headers": {},
    "method": "POST",
    "params": {
        "channel_url": "sendbird_group_channel_269151523_f34ee485e242898bf76ad80e0dgdfsggsg",
        "file": {
            "name": "1689245726751.jpg",
            "type": "image/jpeg",
            "uri": "file:///data/user/0/[REDACTED]cache/ImageManipulator/b9cc839d-f2c6-429b-8b15-3d2127af4db0.jpg"
        }
    },
    "path": "/v3/storage/file",
    "requestId": "rq-ab8fa374-ce60-4ab5-9814-55604dee45f9",
    "requireAuth": true
}

I must admit this was quite time consuming to track down as the error message is very generic. Improving the types for the SDK or returning a more descriptive error message would be very helpful.