I am using Alamofire to upload assets (image/video) as multipart form data. It works fine for file sizes below 300MB (app). When I try to upload a file greater than 300MB, app crashes.
if let video = self.avPlayerItem?.asset as? AVURLAsset {
if let assetData = NSData(contentsOfURL: video.URL) {
multipartFormData.appendBodyPart(data: assetData, name: "file", fileName: "video", mimeType: "video/mp4") // Execution stops here
}
}
I also get the below message from Xcode
How would I support uploading huge sized videos using Alamofire?
Use Stream to upload instead of converting file to NSData which lead to memory problem and occur crash while uploading huge files. sample code