Mesibo Real-time APIs - File Transfer

Estimated reading time: 4 minutes

Just like text messages, mesibo allows you to send and receive any arbitrary file (image, video, doc, etc.) in real-time. Sending and receiving files is no different from sending and receiving text messages. All an application has to do is to upload the file to a server and then send the URL and thumbnail [optional] using mesibo in real-time. The receiver then downloads it using that URL. This out-of-band mechanism ensures that no real-time messages are blocked waiting for large files to be uploaded or downloaded.

mesibo offers you the flexibility to store all files on your own servers including private servers or cloud services like Amazon Web Services, Google Cloud Storage, Microsoft Azure, etc.

There are two ways you can send files using Mesibo:

  • Perform above process manually - upload a file and then send a rich message (say, JSON) containing the file information (e.g., URL, name. title, thumbnail, etc.) using sendMessage API.

  • Alternatively, Mesibo provides convenient helper APIs which does most of the work and allows you to send various other information along with the file such as title, message, geolocation, etc. Receiver is notified of incoming file in listener function mesibo_onFile()

In this section, we will describe these helper APIs.

To start a file transfer (download or upload), you must initialize a FileInfo object and pass it to sendFile or startFileTransfer API. However, instead of creating this object manually, mesibo provides getFileInstance() API, which checks if an existing file transfer for this particular URL (download) or the file (upload) is in progress and if so, returns that object instead of creating a new object. This highly optimizes sending a file by avoiding duplicate file transfers.

Mesibo automatically uploads or downloads files for you. However, Mesibo does not know or mandate how and where you store your files. Hence to use helper APIs, you must assist mesibo in uploading and downloading files to your server. You can achieve this by implementing an upload and download handler functions which are called by mesibo real-time API whenever it needs to upload or download a file.

Following are the file transfer APIs.


Create a new FileInfo instance for a file transfer. It returns the existing object if file transfer is already in progress.

FileInfo getFileInstance(MesiboParams params, long mid, int mode, int type, int source, String filePath, String url, FileTransferListener listener);

getFileInstance takes the following parameters:

Parameter Description
params Message properties (MessageParams) object initialized with required parameters
type type of the transfer, Upload or Download
url download URL (only for Downloads)
filePath File Path (only for Uploads)
source Source of file (any user defined value)
listener File Transfer Listener


Start a File Transfer

boolean startFileTransfer(FileInfo file);

startFileTransfer takes the following parameters:

Parameter Description
file FileInfo object


Stop a File Transfer

boolean stopFileTransfer(FileInfo file);

stopFileTransfer takes the following parameters:

Parameter Description
file FileInfo object


Update the progress of current file Transfer. This API should be called by the FileTransferHandler to update the progress of the file transfer or any error. In turn, it invokes FileTransferProgressListener so that application can update the state, UI, etc.

boolean updateFileTransferProgress(FileInfo file, int progress, int status);

updateFileTransferProgress takes the following parameters:

Parameter Description
file FileInfo object
progress Progress between 0 and 100. It can be negative if the transfer failed
status Status of the transfer


Returns true if FileTransferHandler is implemented by the application

boolean isFileTransferEnabled();

isFileTransferEnabled does not take any parameters.

Refer to (Android) or FileTransfer.m (iOS) in Sample app code on GitHub to learn how to create a file handler.

Voice & Video Calls APIs >>

file transfer api, real-time file sending, file transferring, instance file transfer api, file transfer api for android, file transfer api for ios