Suggest way,method to do ios swift async video upload

ios
swift
twitterkit

#1

using follwing sudo code in swift 2.1
unable to understanding “async upload”

here is what i tried but video doesn’t upload video is of 10 mb and 2 min in length.

let twUploadRequest = client.URLRequestWithMethod("POST", URL: strUploadUrl, parameters:parameters, error: &error)
                    
              client.sendTwitterRequest(twUploadRequest) {
                        (uploadResponse, uploadResultData, uploadConnectionError) -> Void in
                        if (uploadConnectionError == nil) {
                            do {
                                let userinfo: AnyObject! = try NSJSONSerialization.JSONObjectWithData(uploadResultData!, options:NSJSONReadingOptions(rawValue: 0))
                           
                                let collection = userinfo! as! Dictionary<String, AnyObject>
                                let mediaID : AnyObject = collection["media_id_string"] as! String
                                var error: NSError?
                       //////////
                     
                                var parameters_Chk:Dictionary = Dictionary<String, AnyObject>()
                                parameters_Chk = [   "command" : "APPEND", "media_id" : mediaID, "media_data":chunkFirst,"segment_index":"0" ]
                                
                                let twStatusRequestChunk = client.URLRequestWithMethod("POST", URL: strUploadUrl, parameters: parameters_Chk, error: &error)
                                
                                client.sendTwitterRequest(twStatusRequestChunk) { (uploadResponse, uploadResultData, uploadConnectionError) -> Void in
                                //////
                                var parameters_Chunk:Dictionary = Dictionary<String, AnyObject>()
                                parameters_Chunk = [   "command" : "APPEND", "media_id" : mediaID, "media_data":chunkSecond,"segment_index":"1" ]
                                
                                let twStatusRequestChunk = client.URLRequestWithMethod("POST", URL: strUploadUrl, parameters: parameters_Chunk, error: &error)
                                
                                client.sendTwitterRequest(twStatusRequestChunk) { (uploadResponse, uploadResultData, uploadConnectionError) -> Void in
                               
                                    ///
                                    
                                    
                                    var parameters_Append:Dictionary = Dictionary<String, AnyObject>()
                                    parameters_Append = [   "command" : "APPEND", "media_id" : mediaID, "media_data":chunkThird,"segment_index":"2" ]
                                    
                                    let twStatusRequest = client.URLRequestWithMethod("POST", URL: strUploadUrl, parameters: parameters_Append, error: &error)
                                    
                                    client.sendTwitterRequest(twStatusRequest) { (uploadResponse, uploadResultData, uploadConnectionError) -> Void in
                                        
                                        
                                        
                                        var error: NSError?
                                        var parameters_Final:Dictionary = Dictionary<String, AnyObject>()
                                        parameters_Final = ["command":"FINALIZE", "media_id": mediaID]
                                        print(mediaID)
                                        let twStatusRequest = client.URLRequestWithMethod("POST", URL: strUploadUrl, parameters: parameters_Final, error: &error)
                                        
                                        client.sendTwitterRequest(twStatusRequest) { (uploadResponse, uploadResultData, uploadConnectionError) -> Void in
                                            
                                            var parametersStat:Dictionary = Dictionary<String, AnyObject>()
                                            parametersStat = ["status": self.captionTextBox.text!, "wrap_links": "true", "media_ids": mediaID]
                                            let twStatusRequest = client.URLRequestWithMethod("POST", URL: strStatusUrl, parameters: parametersStat, error: &error)
                                            
                                            client.sendTwitterRequest(twStatusRequest) { (uploadResponse, uploadResultData, uploadConnectionError) -> Void in