Home > AI > IOS > Foundation >

uploadTask(with:from:completionHandler:)

Creates a task that performs an HTTP request for the specified URL request object, uploads the provided data, and calls a handler upon completion.

Parameters

request

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.bodyData

The body data for the request.completionHandler

The completion handler to call when the load request is complete. This handler is executed on the delegate queue.

If you pass nil, only the session delegate methods are called when the task completes, making this method equivalent to the uploadTask(with:from:) method.

This completion handler takes the following parameters:data

The data returned by the server.response

An object that provides response metadata, such as HTTP headers and status code. If you are making an HTTP or HTTPS request, the returned object is actually an HTTPURLResponse object.error

An error object that indicates why the request failed, or nil if the request was successful.

Leave a Reply