upload(for:fromFile:delegate:)
Uploads data to a URL and delivers the result asynchronously.
Declaration
func upload(for request: URLRequest, fromFile fileURL: URL, delegate: (any URLSessionTaskDelegate)? = nil) async throws -> (Data, URLResponse)Parameters
- request:
A URL request object that provides request-specific information such as the URL, cache policy, request type, and body data or body stream.
- fileURL:
A file URL containing the data to upload.
- delegate:
A delegate that receives life cycle and authentication challenge callbacks as the transfer progresses.
Return Value
An asynchronously-delivered tuple that contains any data returned by the server as a Data instance, and a URLResponse.