Extending Magnet Message: Add message file attachments.


message_extend_file_transfer

Our plan is to constantly add features and functionality to Magnet Message. I know that many users working in enterprise messaging are looking to do more with the tools provided them. We were looking to illustrate the best way to extend our platform’s capabilities for new use cases. Basic file transfer was at the top of our list. Adding basic file attachments to messages was a simple process. Here is how I approached it on iOS.

One approach would be to split the file up into smaller payloads and send a series of messages across. This did not appeal to me because of the complexity it could add on the receiving side. Even though the platform guarantees message order for one to one messaging PubSub would be more difficult. Messages could be mixed because many users could post at the same time.

My solution was to piggyback on existing services the enterprise is already using. The plan was to upload the file to Amazon S3 and then send the URL across as part of the message meta data. I take advantage of the AFAmazonS3Manager cocoapod for interfacing with S3. Even though my current example uses Amazon S3 the same approach could apply to Box, DropBox, OwnCloud, etc. By using an existing service I only needed a few hours to gain the functionality I wanted. I implemented the new method in a category on MMXMessage. Using a category is a convenient way to add functionality to Magnet Message.

In this case I uploaded the file to S3 and added the URL to the message content. The attachment can now be easily downloaded by the recipient of the message. A major advantage of decoupling the file attachment from the message is that the attachment can be downloaded when it is actually needed. If the attachment came as part of the message it would increase bandwidth usage and local storage needs.

The method signature is a bit rough but the goal for now was functionality. I will iterate on it before we add it in to the core SDK. I would love it if anyone would take on the challenge of adding addition services like Box, Dropbox, etc.

[download id=”2594″]