<!--
{
  "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/URLSession/uploadTask(withStreamedRequest:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSURLSession(im)uploadTaskWithStreamedRequest:"
  },
  "title" : "uploadTask(withStreamedRequest:)"
}
-->

# uploadTask(withStreamedRequest:)

Creates a task that performs an HTTP request for uploading data based on the specified URL request.

```
func uploadTask(withStreamedRequest request: URLRequest) -> URLSessionUploadTask
```

## 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, and the session calls its delegate’s [`urlSession(_:task:needNewBodyStream:)`](/documentation/Foundation/URLSessionTaskDelegate/urlSession(_:task:needNewBodyStream:)) method to provide the body data.

## Return Value

The new session upload task.

## Discussion

An HTTP upload request is any request that contains a request body, such as a `POST` or `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()`](/documentation/Foundation/URLSessionTask/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(_:task:needNewBodyStream:)`](/documentation/Foundation/URLSessionTaskDelegate/urlSession(_:task:needNewBodyStream:)) method that provides the body data to upload.

---

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)