---
title: "uploadTask(withStreamedRequest:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/urlsession/uploadtask(withstreamedrequest:)"
---

# uploadTask(withStreamedRequest:)

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

## Declaration

```swift
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 doc://com.apple.foundation/documentation/Foundation/URLSessionTaskDelegate/urlSession(_:task:needNewBodyStream:) method to provide the body data.

## Mentioned in

Uploading streams of data

## Return Value

Return Value The new session upload task.

## Discussion

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() 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:) method that provides the body data to upload.

## See Also

### Adding upload tasks to a session

- [Building a resumable upload server with SwiftNIO](foundation/building-a-resumable-upload-server-with-swiftnio.md)
- [uploadTask(with:from:)](foundation/urlsession/uploadtask(with:from:).md)
- [uploadTask(with:from:completionHandler:)](foundation/urlsession/uploadtask(with:from:completionhandler:).md)
- [uploadTask(with:fromFile:)](foundation/urlsession/uploadtask(with:fromfile:).md)
- [uploadTask(with:fromFile:completionHandler:)](foundation/urlsession/uploadtask(with:fromfile:completionhandler:).md)
- [uploadTask(withResumeData:)](foundation/urlsession/uploadtask(withresumedata:).md)
- [uploadTask(withResumeData:completionHandler:)](foundation/urlsession/uploadtask(withresumedata:completionhandler:).md)
- [URLSessionUploadTask](foundation/urlsessionuploadtask.md)
- [URLSessionDataDelegate](foundation/urlsessiondatadelegate.md)
