         switch mediaType {
 
         case .Text, .Location:
+
             createMessageWithMessageInfo(messageInfo, failureHandler: failureHandler, completion: { messageID in
 
                 dispatch_async(dispatch_get_main_queue()) {


                guard let
                    data = response.data,
                    json = decodeJSON(data),
                    uploadAttachmentID = json["id"] as? String
                else {
                    failureHandler?(.CouldNotParseJSON, nil)


        default:

            var source: UploadAttachment.Source! // TODO: refactor
            if let filePath = filePath {
                source = .FilePath(filePath)
            }
            if let fileData = fileData {
                source = .Data(fileData)
            }

            let uploadAttachment = UploadAttachment(type: .Message, source: source, fileExtension: mediaType.fileExtension!, metaDataString: metaData)

            tryUploadAttachment(uploadAttachment, failureHandler: failureHandler, completion: { uploadAttachmentID in

                messageInfo["attachment_id"] = uploadAttachmentID

                let doCreateMessage = {
                    createMessageWithMessageInfo(messageInfo, failureHandler: failureHandler, completion: { messageID in
                        dispatch_async(dispatch_get_main_queue()) {
                            let realm = message.realm
                            let _ = try? realm?.write {
                                message.messageID = messageID
                                message.sendState = MessageSendState.Successed.rawValue
                            }

                            completion(success: true)

                            NSNotificationCenter.defaultCenter().postNotificationName(MessageNotification.MessageStateChanged, object: nil)
                        }
                    })
                }

                doCreateMessage()
            })

            /*
            s3UploadFileOfKind(.Message, withFileExtension: mediaType.fileExtension!, inFilePath: filePath, orFileData: fileData, mimeType: mediaType.fileExtension!.mimeType, failureHandler: failureHandler, completion: { s3UploadParams in

                switch mediaType {
