<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.9.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLSessionUploadTask",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSURLSessionUploadTask"
  },
  "title" : "URLSessionUploadTask"
}
-->

# URLSessionUploadTask

A URL session task that uploads data to the network in a request body.

```
class URLSessionUploadTask
```

## Overview

The [`URLSessionUploadTask`](/documentation/Foundation/URLSessionUploadTask) class is a subclass of [`URLSessionDataTask`](/documentation/Foundation/URLSessionDataTask), which in turn is a concrete subclass of [`URLSessionTask`](/documentation/Foundation/URLSessionTask). The methods associated with the [`URLSessionUploadTask`](/documentation/Foundation/URLSessionUploadTask) class are documented in [`URLSessionTask`](/documentation/Foundation/URLSessionTask).

Upload tasks are used for making HTTP requests that require a request body (such as `POST` or `PUT`). They behave similarly to data tasks, but you create them by calling different methods on the session that are designed to make it easier to provide the content to upload. As with data tasks, if the server provides a response, upload tasks return that response as one or more `NSData` objects in memory.

> Note:
> Unlike data tasks, you can use upload tasks to upload content in the background.

When you create an upload task, you provide a [`URLRequest`](/documentation/Foundation/URLRequest) instance that contains any additional headers that you might need to send alongside the upload, such as the content type, content disposition, and so on. In iOS, when you create an upload task for a file in a background session, the system copies that file to a temporary location and streams data from there.

While the upload is in progress, the task calls the session delegate’s [`urlSession(_:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:)`](/documentation/Foundation/URLSessionTaskDelegate/urlSession(_:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:)) method periodically to provide you with status information.

When the upload phase of the request finishes, the task behaves like a data task, calling methods on the session delegate to provide you with the server’s response—headers, status code, content data, and so on.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)