Custom File Upload Handler
How to upload files to a third party host or server
In certain circumstances, the Chat SDK needs to be able to upload files to an external server. Those situations are the following:
Uploading the user's profile image
Uploading thread images
Sending image messages
File upload is decoupled from the main project and is handled by the UploadHandler
service.
In order to customize the upload behavior or upload files to a custom server, it's necessary to create a new upload handler service and then register it with the Chat SDK framework.
The Upload Handler
To make a new upload handler you will need to subclass the AbstractUploadHandler
for Android or the BAbstractUploadHandler
for iOS.
The upload handler only has one method that needs to be implemented:
iOS
To create a custom upload handler, you need to do the following:
Create a new subclass of the
BAbstractUploadHandler
class.Implement the following method:
Register your new upload handler with the framework. In your App Delegate after you have called
BChatSDK.initialize
add the following line of code:
To see an example of how to implement the function, it's recommended to look at the BFirebaseUploadHandler
class which demonstrates a model implementation for Google File Storage.
Android
To create a custom upload handler, you need to do the following:
Create a new subclass of the
AbstractUploadHandler
class.Implement the following method:
Register your new upload handler with the framework. After you have called
ChatSDK.initialize
add the following line of code:
To see an example of how to implement the function, it's recommended to look at the FirebaseUploadHandler
class which demonstrates a model implementation for Google File Storage.
Last updated