Enable or restrict file sharing

You control whether users can share files in your chat, and which types of file extension they can share.

To allow file sharing, first turn it on in the TalkJS dashboard. Then, if you’re targeting Android, configure your app to support this. For iOS, no extra configuration is needed.

Enable file sharing

1. Allow file sharing in your TalkJS dashboard

To allow your users to share files, go to the Chat UI page in the TalkJS dashboard. In the Features section, select the box 'Allow file sharing'.

Overview of chat UI feature options, including a checkbox with the label 'Allow file sharing'.

2. Support file sharing on Android

To enable file uploads on Android, since version 0.7.0 of the TalkJS Flutter SDK you need to add the following inside the <Application> tag of your app's AndroidManifest.xml file:

1<provider
2 android:name="com.talkjs.talkjs_flutter_inappwebview.InAppWebViewFileProvider"
3 android:authorities="${applicationId}.flutter_inappwebview.fileprovider"
4 android:exported="false"
5 android:grantUriPermissions="true">
6 <meta-data
7 android:name="android.support.FILE_PROVIDER_PATHS"
8 android:resource="@xml/provider_paths" />
9</provider>

Users are now able to share files in your chat.

Result

When file sharing is enabled, a user can share a file in the chat by pressing the paperclip icon in the message field. You can try it out here:

Loading chat...

All files that users share are securely saved in the TalkJS database. In some cases, the operating system may prompt the user for permission, such as to access photos. This happens automatically and requires no extra code.

Restrict file sharing

If you would like to allow file sharing only for one group of users but not others, you can do so by using roles. In your TalkJS dashboard, create a separate role for each user group and adjust the file sharing settings per role.

Allowed file extensions

By default, users can share files with the following extensions:

  • .7z
  • .aac
  • .ai
  • .aif
  • .aiff
  • .arj
  • .avi
  • .bmp
  • .bz2
  • .csv
  • .docx
  • .flac
  • .gif
  • .gz
  • .ics
  • .jpeg
  • .jpg
  • .lha
  • .log
  • .m4a
  • .md
  • .mid
  • .midi
  • .mkv
  • .mov
  • .mp3
  • .mp4
  • .mpeg
  • .oga
  • .ogg
  • .ogv
  • .opus
  • .pdf
  • .png
  • .pptx
  • .psd
  • .qt
  • .sit
  • .svg
  • .tar
  • .tif
  • .tiff
  • .ts
  • .txt
  • .wav
  • .webm
  • .xls
  • .xlsx
  • .zip

Is your preferred file extension missing from this list? Or would you like to disallow certain extensions? Get in touch and a member of the TalkJS team will get this sorted for you.