---
title: "cancel(byProducingResumeData:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/urlsessionuploadtask/cancel(byproducingresumedata:)"
---

# cancel(byProducingResumeData:)

Cancels an upload and calls the completion handler with resume data for later use. resumeData will be nil if the server does not support the latest resumable uploads Internet-Draft from the HTTP Working Group, found at https://datatracker.ietf.org/doc/draft-ietf-httpbis-resumable-upload/

## Declaration

```swift
func cancel(byProducingResumeData completionHandler: @escaping @Sendable (Data?) -> Void)
```

```swift
func cancelByProducingResumeData() async -> Data?
```

## Parameters

- `completionHandler`: The completion handler to call when the upload has been successfully canceled.
