Contents

saveBestRepresentation(for:to:contentType:completion:)

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

Declaration

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

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 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.

Mentioned in

Discussion

Creating high-quality thumbnails often involves compressing a 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.