Creates a task that performs an HTTP request for uploading data based on the specified URL request.
- iOS 7.0+
- macOS 10.9+
- UIKit for Mac 13.0+Beta
- tvOS 9.0+
- watchOS 2.0+
A URL request object that provides the URL, cache policy, request type, and so on. The body stream and body data in this request object are ignored, and the session calls its delegate’s
URLSession:method to provide the body data.
task: need New Body Stream:
The new session upload task.
An HTTP upload request is any request that contains a request body, such as a
PUT request. Upload tasks require you to provide a request object so that you can provide metadata for the upload, such as HTTP request headers.
After you create the task, you must start it by calling its
resume method. The task calls methods on the session’s delegate to provide you with the upload’s progress, response metadata, response data, and so on. The session’s delegate must have a
URLSession: method that provides the body data to upload.