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.
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'.
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<provider2 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-data7 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.
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:
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.
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.
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
- .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.