API for sending attachments in Rocket Chat LiveChat (Omnichannel) with Flutter

1k Views Asked by At

Currently, I am developing mobile app, where Rocket Chat LiveChat used for "online customer support" page. And in the docs of rocket chat omnichannel page, I couldn't find anything about sending attachments in LiveChat (Omnichannel). (I know authorized users can send attachments, but in omnichannel there will be non-authorized users)

So does Rocket Chat supports sending attachments in LiveChat.

1

There are 1 best solutions below

1
On BEST ANSWER

For uploading files (in flutter):

final BaseURL = '$baseUrl/api/v1/livechat/upload/$_roomId';

 var result = await Dio().post(url,
        options: Options(
          headers: {
            'x-visitor-token': visitorToken,
          },
        ),
 data: formData);

For downloading uploaded file:

await Dio().download(
                 '$BaseUrl/$fileDownloadLink',
                    '$pathToDownload/$fileName',
                    options: Options(headers: {
                      'cookie':
                          'rc_uid=${u.sId}; rc_rid=$roomId; rc_token=$visitorToken; rc_room_type=l',
                      'Accept-Encoding': ''
                    }));