ios - Network error while uploading multipart data(youTube video) not giving error response -
i using alamofire code uploading youtube video. works fine. suppose if while uploading, switch off net, uploading stops not give me error in response. posting code below:
alamofiremanager.upload(multipartformdata: { (multipartformdata) in let snippetvaluedictionary = requesttype.params let statusvaluedictionary = ["privacystatus":"private"] let videometadictionary = ["snippet":snippetvaluedictionary,"status":statusvaluedictionary] do{ let json = try jsonserialization.data(withjsonobject: videometadictionary, options: jsonserialization.writingoptions.prettyprinted) multipartformdata.append(json, withname: "snippet", mimetype: "application/json") } catch{ } multipartformdata.append(localvideourl, withname: "video", filename: "video.mp4", mimetype: "application/octet-stream") }, to: urlyoutube, method: .post, headers: requesttype.headers, encodingcompletion: { (result) in switch result { case .success(let upload, _, _): upload.uploadprogress(closure: { progress in print("upload progress: \(progress.fractioncompleted)") }).validate().responsejson(completionhandler: { dataresponse in if dataresponse.result.error != nil { print("error description: \(dataresponse.result.error?.localizeddescription)") } else { let json = json(dataresponse.result.value!) print(json) } }) case .failure(let encodingerror): print(encodingerror) } }) when switch off net, uploading stops. when switch on, uploading restarts again , upload progress called. when internet not available while data being uploaded, need error in response user informed network! can please suggest may doing wrong here?
Comments
Post a Comment