<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLSessionUploadTask/cancel(byProducingResumeData:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSURLSessionUploadTask(im)cancelByProducingResumeData:"
  },
  "title" : "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/

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

## Parameters

`completionHandler`

The completion handler to call when the upload has been successfully canceled.

---

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)