---
title: "urlSession(_:task:needNewBodyStreamFrom:completionHandler:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/urlsessiontaskdelegate/urlsession(_:task:neednewbodystreamfrom:completionhandler:)"
---

# urlSession(_:task:needNewBodyStreamFrom:completionHandler:)

Tells the delegate if a task requires a new body stream starting from the given offset. This may be necessary when resuming a failed upload task.

## Declaration

```swift
optional func urlSession(_ session: URLSession, task: URLSessionTask, needNewBodyStreamFrom offset: Int64, completionHandler: @escaping @Sendable (InputStream?) -> Void)
```

```swift
optional func urlSession(_ session: URLSession, needNewBodyStreamForTask task: URLSessionTask, from offset: Int64) async -> InputStream?
```

## Parameters

- `session`: The session containing the task that needs a new body stream from the given offset.
- `task`: The task that needs a new body stream.
- `offset`: The starting offset required for the body stream.
- `completionHandler`: A completion handler that your delegate method should call with the new body stream.
