I have created an application for recording video and upload it to the server, but I meet problem related with huge file size, after some time I get error:
Task <>.<6> finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={_kCFStreamErrorCodeKey=-2102, NSUnderlyingError=0x280562c70 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <>.<6>, _NSURLErrorRelatedURLSessionTaskErrorKey=("LocalDataTask <6C0A7FA8-C553-4D15-9A2F-8D68E028CE51>.<6>">
How can i upload Data(video-data) using Alamofire "multipart form-data"?
AF.upload(
multipartFormData: { multipartFormData in
multipartFormData.append(fileUrl.url, withName: "file", fileName: "testVideo.mp4", mimeType: "video/mp4")
},
to: URLs.COMMENT_URL,
method: .post,
headers: headers
).responseData { response in
print(response.response?.description)
}
}
One of the solution is to increase the default session timeout by -
// Alamofire Session Object
// Expected in Seconds
session.configuration.timeoutIntervalForRequest = 5*60