download(_:decideDestinationUsing:suggestedFilename:completionHandler:)
Asks the delegate to provide a file destination where the system should write the download data.
Declaration
func download(_ download: WKDownload, decideDestinationUsing response: URLResponse, suggestedFilename: String, completionHandler: @escaping @MainActor @Sendable (URL?) -> Void)func download(_ download: WKDownload, decideDestinationUsing response: URLResponse, suggestedFilename: String) async -> URL?Parameters
- download:
The download that needs a file destination where the systems should write the download data.
- response:
A response from the server for an HTTP request, or a synthesized response for a blob download.
- suggestedFilename:
A string with a filename suggestion to use in creating the file destination.
- completionHandler:
A closure you invoke with a destination file URL to begin the download, or
nilto cancel the download.
Discussion
The suggested filename can come from the response or from the web content.
The destination file URL must meet the following requirements:
It’s a file that doesn’t exist.
It’s in a directory that exists.
It’s in a directory that WebKit can write to.