Getting Started Guide

Hosting Media and Files

In this part, we will describe how to host media and files on your server instead of the mesibo file server.

Hosting Media and Files on Your Server

As we learned before, mesibo allows you to send and receive any arbitrary file (image, audio, video, doc, etc) in real-time.

By default, all media and files you send are stored on the mesibo file server. However most mesibo users, especially those having sensitive data (financial institutes, healthcare, dating, etc.) prefer to store files on their servers. We also recommend that you should use the mesibo server only for initial development and use your own servers for deployment.

mesibo offers you the flexibility to store all media and files on your servers including private servers or cloud services like Amazon Web Services, Google Cloud Storage, Microsoft Azure, etc. When you choose to store files on your servers, mesibo does not know how and where you store your files. Hence you must assist mesibo in uploading and downloading files to your server.

There are two ways you can program mesibo to send files to your servers:

Option 1: Setup Upload URL

You can provide an upload URL and a random authentication token to mesibo by calling setUploadUrl.

Mesibo.setUploadUrl("", authenticationToken); 

Where authenticationToken can be any string of your choice. The authenticationToken will be sent along with the file so that you can authenticate your users and secure your uploads.

Mesibo will upload the file to this URL along with the following form parameters:

  • op = "upload"
  • auth = Authentication Token set in setUploadUrl
  • uid = UID of the user
  • mid = Message ID
  • source = Source of the file (message, profile image, group profile image, etc)

Your server should respond with JSON data having the result and the url, for example,

{"result": true, "url": "" }

Option 2: Setup File Transfer Handler (Android and iOS)

In case, setting up an upload URL does not meet your requirements, you can handle upload and download entirely by yourself by implementing upload and download handler functions in FileTransferHandler, which is called by mesibo real-time API whenever it needs to upload or download files from your servers.

For more information, refer to the File Transfer Handler API

Option 2: Setup File Transfer Handler (Javascript)

In case, setting up an upload URL does not meet your requirements, you can handle upload entirely by yourself by implementing an upload handler and use setUploadHandler to set it.

Mesibo.setUploadHandler(function(file, callback) {
	// upload file object

mesibo will call your upload handler with a Javascript file object and a callback when it needs to upload a file. You can then upload a file and call callback with uploaded file URL if the upload was successful, or call callback with null if the upload failed.

If you have any questions, check out the File Handling FAQ