<!--
{
  "availability" : [
    "iOS: 14.0.0 - 18.0.0",
    "iPadOS: 14.0.0 - 18.0.0",
    "macCatalyst: 14.0.0 - 18.0.0",
    "macOS: 11.0.0 - 15.0.0",
    "visionOS: 1.0.0 - 2.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "QuickLookThumbnailing",
  "identifier" : "/documentation/QuickLookThumbnailing/QLThumbnailGenerator/saveBestRepresentation(for:to:contentType:completion:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Quick Look Thumbnailing"
    ],
    "preciseIdentifier" : "c:objc(cs)QLThumbnailGenerator(im)saveBestRepresentationForRequest:toFileAtURL:withContentType:completionHandler:"
  },
  "title" : "saveBestRepresentation(for:to:contentType:completion:)"
}
-->

# saveBestRepresentation(for:to:contentType:completion:)

Saves the best representation of thumbnail for a specific request to the specified URL.

```
func saveBestRepresentation(for request: QLThumbnailGenerator.Request, to fileURL: URL, contentType: String, completion completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

## Parameters

`request`

The request that you used to generate a thumbnail.

`fileURL`

The destination to which you save the generated thumbnail.

`contentType`

The content type of the thumbnail image that you want to save. Use a type that is supported by <doc://com.apple.documentation/documentation/ImageIO/CGImageDestination>, such as `kUTTypePNG` or `kUTTypeJPEG`.

`completionHandler`

The handler to call when saving the thumbnail to disk.

- `error`: An error object that indicates why saving a thumbnail image failed, or `nil` if saving the thumbnail succeeded.

## Discussion

> Important:
> You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration:
> 
> ```swift
> func saveBestRepresentation(for request: QLThumbnailGenerator.Request, to fileURL: URL, contentType: String) async throws
> ```
> 
> For information about concurrency and asynchronous code in Swift, see <doc://com.apple.documentation/documentation/Swift/calling-objective-c-apis-asynchronously>.

Creating high-quality thumbnails often involves compressing a <doc://com.apple.documentation/documentation/CoreGraphics/CGImage> as a `PNG` or `JPEG` file in-process. This task requires more resources than are available in resource-constrained environments such as File Provider Extensions.

Use this method to create and save the thumbnail image outside of your process as it doesn’t impose the same constraints on memory usage.

---

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)