I need to upload an mp4 video file from iPhone/iPad to a server, also in the background, so I read that is possible with URLSession.uploadTask(with: URLRequest, from
solution as of 2020 with native URLSession
to run background upload with uploadTask
and multipart/form-data
:
multipart/form-data
as it required for my NodeJS serverURLSession
:let config = URLSessionConfiguration.background(withIdentifier: "uniqueID")
let session = URLSession(configuration: config, delegate: self, delegateQueue: nil)
// This line is important: here we use withStreamedRequest
let task = session.uploadTask(withStreamedRequest: request)
task.resume()
A little bit about my server side:
Hope this help